Skip to content
run-script creator for npm emulating libraries
Failed to load latest commit information.
lib add options.platform Nov 19, 2014
test [fix] .gitignore fail Oct 17, 2012
.gitignore [fix] .gitignore fail Oct 17, 2012
package.json add options.platform to readme script Nov 19, 2014


Generate spawn options for running package.json scripts


Emulates npm run-script $SCRIPT_NAME

*NOTE: * Does not add in the log wrapping like NPM

var lifecycle = process.argv[2];
getNPMSpawnOptions(process.cwd(), lifecycle, {
  defaultScript: {
    start: 'node server.js',
    preinstall: '[ -f wscript] && (node-waf clean || true; node-waf configure build)'
  env: {
    PATH: process.env.PATH
  fs?: fs_api // defaults to require('fs') used for remote system stuff
  platform?: 'windows' | 'darwin' | 'linux' // target platform
}, function (err, spawnOptions) {
  var script = require('child_process').spawn.apply(null, spawnOptions);
  script.on('exit', process.exit.bind(process));

Differences from NPM

  1. Does not add in defaults for scripts like npm run-scripts start (use options.defaultScript)
  2. Does not auto add in the current path, set it in options.env (will append if already has a value)
  3. Does not change users for you, use something like suspawn


npm help scripts

Something went wrong with that request. Please try again.