Skip to content
forked from timoxley/npm-run

Run locally-installed node module executables.

License

Notifications You must be signed in to change notification settings

gtanner/npm-run

 
 

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

26 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

npm-run

Build Status

Run local executables from node_modules

Makes it easy to run locally-installed package executables in a robust manner. Any executable available to an npm lifecycle script is available to npm-run.

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.

Installation

> npm install -g npm-run

Usage

> npm install mocha
> npm-run mocha test/*
# uses local mocha executable

API

The API of npm-run basically wraps child_process methods such that Any executable available to an npm lifecycle script is on the PATH.

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][, options])

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][, options])

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
})

See Also

License

MIT

About

Run locally-installed node module executables.

Resources

License

Stars

Watchers

Forks

Packages

No packages published

Languages

  • JavaScript 100.0%