I wrote a simple module in CoffeeScript, but I want to publish the compiled JavaScript to NPM. I don't want to manually run the coffee
command each time, that's too much typing and I'll probably forget and publish stale js every now and then.
I know there's some combination of npm package.json script hooks and CoffeeScript cli arguments that will do the trick, but I forget the particulars. How's it go again?
A basic package.json setup for the conventional directory structure looks like
"scripts": {
"prepublish": "coffee --compile --output lib/ src/"
}
If you also want to compile coffeescript before running tests, you likely want to pull the compilation step out as a reusable script:
"scripts": {
"pretest": "npm run compile",
"prepublish": "npm run compile",
"test": "mocha",
"compile": "coffee --compile --output lib/ src/"
}