You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Integration of option in command.ls. Not exactly elegant yet.
# command.ls#L148
# Write out a JavaScript source file with the compiled code. By default, files
# are written out in `cwd` as `.js` files with the same name, but the output
# directory can be customized with `--output`.
!function write-JS source, js, base, json
# foo.ls => foo.js
# foo.jsm.ls => foo.jsm
ext = 'X' if o.exe
ext = '.json' if json
extension = if ext is void then '.js' else ext
filename = path.basename(source)replace do
/(?:(\.\w+)?\.\w+)?$/ -> &1 or ext
filename = filename.replace /X$/, ''
dir = path.dirname source
if o.output
dir = path.join that, dir.slice if base is '.' then 0 else base.length
js-path = path.join dir, filename
if o.exe
js = "#!/usr/bin/env node\n\n" + js
!function compile
e <-! fs.write-file js-path, js || '\n'
return warn e if e
util.log "#source => #js-path" if o.watch
# add executable flag to js file
if o.exe
say "executable", js-path
xe <- fs.chmod js-path, '0755'
return warn xe if xe
e <-! fs.stat dir
return compile! unless e
require 'child_process' .exec do
"mkdir #{['-p' unless /^win/test process.platform]} #dir" compile
Yes, I set it up via npm "bin" field now, but whenever I save the .ls file, it generates the js file to be non executable in a function wrapper and ditches my #!/usr/bin/env node comment. Would be super if it could detect this type of comment and not ditch it :)
You can put the shebang in JS-backticks and it will be preserved. npm should chmod +x it. You can get rid of the function wrapper with the -b option of lsc.
Activity
[-]Introducing "executable" js option - how can I test it?[/-][+]Introducing "executable" js option[/+]gkz commentedon Oct 7, 2014
I'm not exactly sure of the purpose of this option.
Is the idea to prepend ""#!/usr/bin/env node" to the outputted JS?
apaleslimghost commentedon Oct 7, 2014
And apparently also to chmod and install it somewhere. This should be done via
npm, using thebinfield of package.json.kristianmandrup commentedon Oct 7, 2014
Thanks :)
kristianmandrup commentedon Oct 9, 2014
Yes, I set it up via npm "bin" field now, but whenever I save the .ls file, it generates the js file to be non executable in a function wrapper and ditches my
#!/usr/bin/env nodecomment. Would be super if it could detect this type of comment and not ditch it :)apaleslimghost commentedon Oct 9, 2014
You can put the shebang in JS-backticks and it will be preserved. npm should chmod +x it. You can get rid of the function wrapper with the
-boption oflsc.kristianmandrup commentedon Oct 11, 2014
Didn't work ;/P
vendethiel commentedon Oct 11, 2014
You need more backticks. Otherwise it's infix function application.
apaleslimghost commentedon Oct 12, 2014
kristianmandrup commentedon Oct 12, 2014
Yes, thanks! Works just fine :)
Matthew-Davey commentedon Oct 2, 2015
I was just about to raise an issue for this, glad I searched the archive first! 👍