How to compile coffeescript before publishing to NPM?

I wrote a simple module in CoffeeScript, but I want to publish compiled JavaScript for NPM. I don't want to manually run the coffee command every time, which prints too much, and I will probably forget and publish obsolete js from time to time.

I know some combinations of npm package.json script hooks and CoffeeScript cli arguments that will do the trick, but I forgot the details. How does this happen again?

+1
npm package coffeescript
04 Oct '14 at 19:54
source share
1 answer

The basic installation of package.json for a traditional directory structure looks like

 "scripts": { "prepublish": "coffee --compile --output lib/ src/" } 

If you also want to compile coffeescript before running the tests, most likely you will want to output the compilation output as a reusable script:

 "scripts": { "pretest": "npm run compile", "prepublish": "npm run compile", "test": "mocha", "compile": "coffee --compile --output lib/ src/" } 
+5
04 Oct '14 at 19:54
source share



All Articles