Compiling coffee binaries
If I am writing my entire project in CoffeeScript, how do I write my binaries?
#!/usr/bin/env coffee
# My program sits here
Then, after compiling, I lose the shebang:
// Generated by CoffeeScript 1.4.0
// My program sits here
I was hoping it would turn into something like:
#!/usr/bin/env node
// My program sits here
Is it possible? Or I need to rethink the way I work.
source to share
The trick is to NOT put the .coffee extension in your "binary" file and compile it.
I also recommend not placing signficant logic in binary. Most likely you have a binary starter source.
In general, each of my binaries are in a directory /bin
from the root of my project and only have these two lines (for example, my CoffeeDocTest project on GitHub here ):
#!/usr/bin/env coffee
require(__dirname + '/../src/coffeedoctest')
You will also want to run chmod 755 <filename>
on it to make it executable.
Look here for an example of how main starts coffeedoctest.coffee
and handles command line options etc.
source to share