Skip to content

Instantly share code, notes, and snippets.

@shrunyan
Created February 6, 2017 19:55
Show Gist options
  • Save shrunyan/f218fe7dd3678fd8d93279cb8d8f774f to your computer and use it in GitHub Desktop.
Save shrunyan/f218fe7dd3678fd8d93279cb8d8f774f to your computer and use it in GitHub Desktop.
npm prestart script for triggering sub-app builds
// @see https://strongloop.com/strongblog/modular-node-js-express/
var fs = require('fs')
var resolve = require('path').resolve
var join = require('path').join
var cp = require('child_process')
// get library path
var src = resolve(__dirname, '../src/')
fs.readdirSync(src)
.forEach((app) => {
var appPath = join(src, app)
// ensure path has package.json
if (!fs.existsSync(join(appPath, 'package.json'))) return
// install folder
cp.spawn('npm', ['run', 'build'], {
env: process.env,
cwd: appPath,
stdio: 'inherit'
})
})
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment