execSync
Node's missing execSync.
Last updated 6 years ago by mgutz .
MIT · Repository · Bugs · Original npm · Tarball · package.json
$ cnpm install execSync 
SYNC missed versions from official npm registry.

execSync

Executes shell commands synchronously.

WARNING For dev machine shell scripting only. DO NOT USE for production servers.

Install

Windows requires Python and Visual Studio 2012 (Express) installed for node to build. See node-gyp installation. Pre-built binaries for node v0.8 and node v0.10 are packaged. They should work and if not try manually building.

npm install execSync

Sometimes a manual build is necessary on Windows even with all the tools in place, replace Visual Studio version with '2010' or '2012' based on the version installed.

npm install node-gyp -g
node-gyp rebuild --msvs_version=2012

Usage

Require it

var sh = require('execSync');

Run does not capture output.

var code = sh.run('echo $USER; echo some_err 1>&2; exit 1');
console.log('return code ' + code);

Use the less efficient exec if you need output. exec is just redirection trickery around run.

var result = sh.exec('echo $USER; echo some_err 1>&2; exit 1');
console.log('return code ' + result.code);
console.log('stdout + stderr ' + result.stdout);

Notes

In *nix and OSX version commands are run via sh -c YOUR_COMMAND

In Windows commands are run via cmd /C YOUR_COMMAND

License

Copyright (c) 2012, 2013 Mario Gutierrez mario@mgutz.com

See the file LICENSE for copying permission.

Current Tags

  • 1.0.2                                ...           latest (6 years ago)

7 Versions

  • 1.0.2                                ...           6 years ago
  • 1.0.1-pre                                ...           7 years ago
  • 1.0.0-pre                                ...           7 years ago
  • 0.0.4                                ...           7 years ago
  • 0.0.3                                ...           7 years ago
  • 0.0.2                                ...           7 years ago
  • 0.0.1                                ...           8 years ago
Maintainers (1)
Downloads
Today 2
This Week 51
This Month 211
Last Day 49
Last Week 255
Last Month 1,342
Dependencies (1)
Dev Dependencies (2)
Dependents (229)

Copyright 2014 - 2016 © taobao.org |