LiveScript icon indicating copy to clipboard operation
LiveScript copied to clipboard

How to get rid of surrounding paranthesis in compiled output?

Open ceremcem opened this issue 9 years ago • 5 comments

By issuing this command:

$ echo {+x} | lsc -cpb --no-header

I get following result

({
  x: true
});

but I need

{
  x: true
}

Is there any way to do this without getting regex come into play?

ceremcem avatar Jul 08 '16 14:07 ceremcem

$ echo {+x} | lsc -cpb --no-header --bare

sourcevault avatar Jul 08 '16 16:07 sourcevault

Would you test your suggested code?

ceremcem avatar Jul 08 '16 17:07 ceremcem

dont have bash.

sourcevault avatar Jul 08 '16 17:07 sourcevault

Does echo {+x} | lsc -j come close enough? That gets you

{
  "x": true
}

rhendric avatar Jul 08 '16 17:07 rhendric

That works (does what I asked), thank you. But it turns out that this can be applied only JSON objects which don't include functions in them:

echo "{x: ->}" | lsc -cpb --no-header 

outputs

({
  x: function(){}
});

but

echo "{x: ->}" | lsc -cpb --no-header -j

outputs:

{}

ceremcem avatar Jul 08 '16 17:07 ceremcem