5.0.1 • Published 6 years ago

npm-run v5.0.1

Weekly downloads
69,959
License
MIT
Repository
github
Last release
6 years ago

npm-run

NPM NPM

Build Status

Run executables in node_modules from the command-line

Use npm-run to ensure you're using the same version of a package on the command-line and in package.json scripts.

Any executable available to an npm lifecycle script is available to npm-run.

Usage

> npm install mocha # mocha installed in ./node_modules
> npm-run mocha test/* # uses locally installed mocha executable 
> npm-run --help
Usage: npm-run command [...args]
Options:
  --version  Display version & exit.
  --help     Display this help & exit.

Hint: to print augmented path use:
npm-run node -p process.env.PATH

Installation

> npm install -g npm-run

Programmatic API

The API of npm-run basically wraps core child_process methods (exec, spawn, etc) such that locally install package executables will be on the PATH when the command runs.

npmRun(command, options, callback)

Alias of npmRun.exec.

npmRun.exec(command, options, callback)

Takes same arguments as node's exec.

npmRun.exec('mocha --debug-brk --sort', {cwd: __dirname + '/tests'}, function (err, stdout, stderr) {
  // err Error or null if there was no error
  // stdout Buffer|String
  // stderr Buffer|String
})

npmRun.sync(command, options)

Alias of npmRun.execSync

npmRun.execSync(command, options)

Takes same arguments as node's execSync.

var stdout = npmRun.execSync(
  'mocha --debug-brk --sort',
  {cwd: __dirname + '/tests'}
)
stdout // command output as Buffer|String

npmRun.spawnSync(command, args)

Takes same arguments as node's spawnSync.

var child = npmRun.spawnSync(
  'mocha',
  '--debug-brk --sort'.split(' '),
  {cwd: __dirname + '/tests'}
)
child.stdout // stdout Buffer|String
child.stderr // stderr Buffer|String
child.status // exit code

npmRun.spawn(command, args)

Takes same arguments as node's spawn.

var child = npmRun.spawn(
  'mocha',
  '--debug-brk --sort'.split(' '),
  {cwd: __dirname + '/tests'}
)
child.stdout // stdout Stream
child.stderr // stderr Stream
child.on('exit', function (code) {
  code // exit code
})

Why

Due to npm's install algorithm node_modules/.bin is not guaranteed to contain your executable. npm-run uses the same mechanism npm uses to locate the correct executable.

See Also

License

MIT

ams-front-clilive-packagerctvheritagebotbyted-fe-ci@alextheartisan/generator@crisp-dynamics/cli@infinitebrahmanuniverse/nolb-npm-r@everything-registry/sub-chunk-2343gulp-npmrunjovographql-boilerplate-installgrapecity-api-doc-generatorgrapecity-cary-api-doc-generatorjsdoc-generatorjsrunluis-version-toolsgulp-snykimpeditmodizoarloading-infomd-jsx-html@htho/npm-dtsesformatter2esformatterflush-npmfiredev-frameworkfirebase-cloud-ts-genfie-taskenzyme-adapter-react-helpergenerate-ngrxgenerator-abck@netbasal/spectator-clipackage-version-checkngx-tslint-report@kalamazoo/build-utils@kalamazoo/ci-scripts@kalamazoo/measure@jwalsh/graphql-clinpm-dtsnpfmnpm-add-dependencies@mediacologne/tslint-html-reportnpm-tasks@mklabs/npfm@mustang/cli@mooyoojs/taro-rax-runnernpm-workshopnpm-tutorng2-preloaderng2-accordionsngrx-genngrx-generatorng-skeleton-generatorng2-button-loader@ls-age/ci@journeyapps-solutions/rocket-pdf@kondi/fast-skip@jakehamilton/dts-webpack-plugin@jayphelps/jay-scripts@opentiny/cli-devkit@opentiny/tiny-toolkit-devminder@itandu/renderermicro-scriptsmorphi@inversion-of-control/client-project@inversion-of-control/ecmascript-project@inversion-of-control/electron-projectpwac@rucken/clirazor-react-bundler@robo54/react-scripts@rootplace/stapleprisma-cli-core@fabiospampinato/tram@shonaui/core@thermopylae/dev.environmentadd-dependencies@werkspot/lingui@alantech/react-cli@uidu/build-utils@strangeanimals/add-dependenciesrebird-https-letsencrypt@sugoi/cli@atlaskit/build-utils@atlaskit/measuretanktattoo@cromwell/rendererswaggingbuild-react-librarytypescript-apptslint-html-reportclinbrain-clicms-adaptercreate-logan-apicreate-modular-appunikum-frontend-toolboxstatic-site-scaffold
5.0.1

6 years ago

5.0.0

6 years ago

4.1.2

7 years ago

4.1.1

7 years ago

4.1.0

8 years ago

4.0.1

8 years ago

4.0.0

8 years ago

3.0.0

8 years ago

2.0.0

9 years ago

1.1.1

9 years ago

1.1.0

9 years ago

1.0.2

10 years ago

1.0.1

10 years ago

1.0.0

10 years ago