JSPM

npm-script

1.2.0
  • ESM via JSPM
  • ES Module Entrypoint
  • Export Map
  • Keywords
  • License
  • Repository URL
  • TypeScript Types
  • README
  • Created
  • Published
  • Downloads 60
  • Score
    100M100P100Q58255F
  • License MIT

NPM run-script spawning options generator

Package Exports

  • npm-script

This package does not declare an exports field, so the exports above have been automatically detected and optimized by JSPM instead. If any package subpath is missing, it is recommended to post an issue to the original package (npm-script) to support the "exports" field. If that is not possible, create a JSPM override to customize the exports field for this package.

Readme

npm-script

Generate spawn options for running package.json scripts

Example

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)'
  }[lifecycle],
  env: {
    PATH: process.env.PATH
  },
  fs?: fs_api // defaults to require('fs') used for remote system stuff
}, function (err, spawnOptions) {
  var script = require('child_process').spawn.apply(null, spawnOptions);
  script.stderr.pipe(process.stderr);
  script.stdout.pipe(process.stdout);
  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

See

npm help scripts