I'm building an app consisting of private npm repos built in CoffeeScript. To keep deployment language-agnostic, and allow each app to specify its version of CoffeeScript, I'm including CoffeeScript as a dependency in each library, and building into JavaScript upon npm installation.
npm installation works fine for standalone repos, but fails when I try to install a repo that depends on another repo being built.
So if I have repo-a
, whose package.json
includes this:
"dependencies": {
"coffee-script": "~1.2.0"
},
"scripts": {
"install": "./node_modules/coffee-script/bin/cake install"
}
and repo-b
, whose package.json
includes this:
"dependencies": {
"coffee-script": "~1.2.0",
"repo-a": "git+ssh://git@mydomain.com:myrepo.git"
},
"scripts": {
"install": "./node_modules/coffee-script/bin/cake install"
}
where both have a Cakefile
that looks like this, with an install
task called on an npm install
hook:
{print} = require "util"
{spawn} = require "child_process"
coffee = "./node_modules/coffee-script/bin/coffee"
echo = (child) ->
child.stdout.on "data", (data) -> print data.toString()
child.stderr.on "data", (data) -> print data.toString()
child
install = (cb) ->
console.log "Building..."
echo child = spawn coffee, ["-c", "-o", "lib", "src"]
child.on "exit", (status) -> cb?() if status is 0
task "install", "Install, build, and test repo", install
npm install
works for for repo-a
, but fails for repo-b
with this message:
sh: ./node_modules/coffee-script/bin/cake: No such file or directory
at which point an unfinished ___coffee-script.npm
directory exists in node_modules
.
Of course it would be much easier to use a app.js wrapper, but I need to deploy JavaScript, not CoffeeScript. Can anyone tell me how I could get this to work?