node-exec-cmd

0.1.2 • Public • Published

node-exec-cmd

Execute cmd cross platform using, returning Promise.

Install

  • npm install node-exec-cmd

Usage Examples

var execCmd = require('node-exec-cmd');

execCmd('ls -l')
    .then(function (output) {
        console.log(output);
        // example print:
        //    total 16
        //    -rw-r--r--  1 yunfei  staff  1361 11  2 19:57 exec-cmd.js
        //    -rw-r--r--  1 yunfei  staff    46 11  2 19:57 package.json
    });

execCmd('npm run no-such-script')
    .catch(function (output) {
        console.log(output);
        // example print:
        //    npm ERR! Darwin 15.3.0
        //    npm ERR! argv "/usr/local/Cellar/node4-lts/4.4.4/bin/node" "/usr/local/bin/npm" "run" "no-script"
        //    npm ERR! node v4.4.4
        //    npm ERR! npm  v3.10.8
    });

execCmd('npm install', {logDetail: true})
  .then(function (output) {
      // output will be EMPTY cause it's piped to process.stdio
  });

execCmd('pm2 start', {bg: true});
  .then(function () {
      // Start a background task. Promise will be immediately resolved
  });

Readme

Keywords

Package Sidebar

Install

npm i node-exec-cmd

Weekly Downloads

0

Version

0.1.2

License

MIT

Last publish

Collaborators

  • adventure-yunfei