{"_id":"node-run-cmd","_rev":"6-4d0aad429ebbef5673decbc9a4b7bc73","name":"node-run-cmd","description":"Easily run console/terminal command(s) from Node","dist-tags":{"latest":"1.0.1"},"versions":{"1.0.0":{"name":"node-run-cmd","version":"1.0.0","description":"Easily run console/terminal command(s) from Node","main":"index.js","scripts":{"test":"mocha"},"repository":{"type":"git","url":"git+https://github.com/c-h-/node-run-cmd.git"},"keywords":["node","console","terminal","bash","command","shell"],"author":{"name":"Charlie Hulcher"},"license":"MIT","bugs":{"url":"https://github.com/c-h-/node-run-cmd/issues"},"homepage":"https://github.com/c-h-/node-run-cmd#readme","devDependencies":{"chai":"^3.5.0","chai-as-promised":"^5.3.0","mocha":"^2.5.2","sinon":"^1.17.4","sinon-chai":"^2.8.0"},"gitHead":"b47c511055def670f168dbf7e3e4e1db9cf61ce0","_id":"node-run-cmd@1.0.0","_shasum":"6cfb4b35544f8508b987630e8fd070e9b66fb615","_from":".","_npmVersion":"3.3.12","_nodeVersion":"5.1.0","_npmUser":{"name":"c-h-","email":"charlie.hulcher@gmail.com"},"dist":{"shasum":"6cfb4b35544f8508b987630e8fd070e9b66fb615","tarball":"https://registry.npmjs.org/node-run-cmd/-/node-run-cmd-1.0.0.tgz","integrity":"sha512-WyZi9p7Pz05vC7Ca2hj6/Lp+PyFwNxt+5Y8g/2EoQBz+6RMF5IX566ltjC5Uhw8TwapxbbAZjctFZ/+QsP6C/w==","signatures":[{"keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA","sig":"MEUCIDxJHsCwfShI/smCf8Mncacz+5B8VS1sLhJJlvFXi3SZAiEA2X+dYPfkgb4MI7AmYO92pnWHPOb2bEfuGN3Qw+Nckds="}]},"maintainers":[{"name":"c-h-","email":"charlie.hulcher@gmail.com"}],"_npmOperationalInternal":{"host":"packages-16-east.internal.npmjs.com","tmp":"tmp/node-run-cmd-1.0.0.tgz_1464192541864_0.3435134117025882"}},"1.0.1":{"name":"node-run-cmd","version":"1.0.1","description":"Easily run console/terminal command(s) from Node","main":"index.js","scripts":{"test":"mocha"},"repository":{"type":"git","url":"git+https://github.com/c-h-/node-run-cmd.git"},"keywords":["node","console","terminal","bash","command","shell"],"author":{"name":"Charlie Hulcher"},"license":"MIT","bugs":{"url":"https://github.com/c-h-/node-run-cmd/issues"},"homepage":"https://github.com/c-h-/node-run-cmd#readme","devDependencies":{"chai":"^3.5.0","chai-as-promised":"^5.3.0","mocha":"^2.5.2","sinon":"^1.17.4","sinon-chai":"^2.8.0"},"gitHead":"fd2d426509247d385ab9197899a028f61b8be414","_id":"node-run-cmd@1.0.1","_shasum":"1755c12624bdff920d8f45242d6642e214a3d400","_from":".","_npmVersion":"3.3.12","_nodeVersion":"5.1.0","_npmUser":{"name":"c-h-","email":"charlie.hulcher@gmail.com"},"dist":{"shasum":"1755c12624bdff920d8f45242d6642e214a3d400","tarball":"https://registry.npmjs.org/node-run-cmd/-/node-run-cmd-1.0.1.tgz","integrity":"sha512-OUePfObrxlzQa3NE9QFUGgyPvTi81/fV41gwSU+HE4tZ7sEHiRC+O88gjw68WXp7BSj9uWjEbdEv4ei0117ffA==","signatures":[{"keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA","sig":"MEQCIH1RlBzc8c6AdMwJhlPrA8puolYuu70WzN5q9yoSK/RDAiB/dQmwAkSV/UNIjm3X5E4hX5V2Ouf/iqsA/CE0+S+7rg=="}]},"maintainers":[{"name":"c-h-","email":"charlie.hulcher@gmail.com"}],"_npmOperationalInternal":{"host":"packages-12-west.internal.npmjs.com","tmp":"tmp/node-run-cmd-1.0.1.tgz_1464200673774_0.35011654859408736"}}},"readme":"# node-run-cmd\n-\n*Node.js commandline/terminal interface.*\n\nEasily run simple or sophisticated console/terminal command(s) from Node. Supports sequential and parallel execution. Returns a promise that resolves to an array of exit codes for each command run.\n\nWith node-run-cmd you can execute a single command or an array of commands quite simply.\n\nIf you want, set in-depth options for commands being run, including callbacks for data, errors, and completion. Also set working directory, environment variables, run execution process in detached mode, set the uid and gid for the execution process(es), and set the shell to run the command in.\n\nThe source that this package is based on has been in production since February, 2016. Note that the examples here are for illustrative purposes only; most of the time there is no real need to run commands from Node, and they should be avoided if there are cross-platform requirements. This package aims to help when there isn't an agreeable alternative.\n\nIf most of your commands are filesystem related, I would instead look to [node-fs-extra](https://github.com/jprichardson/node-fs-extra) to accomplish what the commands would have.\n\n##### NPM:\n![node-cmd npm version](https://img.shields.io/npm/v/node-run-cmd.svg) ![supported node version for node-cmd](https://img.shields.io/node/v/node-run-cmd.svg) ![total npm downloads for node-cmd](https://img.shields.io/npm/dt/node-run-cmd.svg) ![monthly npm downloads for node-cmd](https://img.shields.io/npm/dm/node-run-cmd.svg) ![npm licence for node-cmd](https://img.shields.io/npm/l/node-run-cmd.svg)\n\n##### GitHub:\n![node-run-cmd GitHub Release](https://img.shields.io/github/release/c-h-/node-run-cmd.svg) ![GitHub license node-run-cmd license](https://img.shields.io/github/license/c-h-/node-run-cmd.svg) ![open issues for node-run-cmd on GitHub](https://img.shields.io/github/issues/c-h-/node-run-cmd.svg)\n\nLicensed via MIT License.\n\n-\n\n## Quick Start\nThe quickest way to get started is to run a single, simple command, then increase complexity as needed.\n\nInstall the package:\n```shell\n$ npm install --save node-run-cmd\n```\n\nUse the package:\n```javascript\nvar nrc = require('node-run-cmd');\nnrc.run('mkdir foo');\n```\n\n## Examples\nThese examples get increasingly complex to demonstrate the robustness of the package. Not all options are demonstrated; see the Options Object section for all possible options.\n\n### Simple command\n```javascript\nnrc.run('mkdir foo');\n```\n\n### Aysnchronous usage\n#### Promise style\n```javascript\nnrc.run('mkdir foo').then(function(exitCodes) {\n  doSomethingElse();\n}, function(err) {\n  console.log('Command failed to run with error: ', err);\n});\n```\n#### Callback style\n```javascript\nvar callback = function (exitCodes) {\n  doSomethingElse();\n};\nnrc.run('mkdir foo', { onDone: callback } );\n```\n\n### Use output (stdout) from command\n```javascript\nvar dataCallback = function(data) {\n  useData(data);\n};\nnrc.run('ls', { onData: dataCallback });\n```\n\n### Use error output (stderr) from command\n```javascript\nvar errorCallback = function(data) {\n  useErrorData(data);\n};\nnrc.run('ls ~/does/not/exist', { onError: dataCallback });\n```\n\n### Use exit code from command\n```javascript\nvar doneCallback = function(code) {\n  useCode(code);\n};\nnrc.run('ls foo', { onDone: doneCallback });\n```\n*OR*\n```javascript\nnrc.run('ls foo').then(function(codes){ useCode(codes[0]); });\n```\n\n### Run multiple commands\n```javascript\nnrc.run([ 'mkdir foo', 'touch foo/bar.txt' ]);\n```\n\n### Set working directory for commands\n```javascript\nvar commands = [\n  'mkdir foo',\n  'touch foo/bar.txt'\n];\nvar options = { cwd: 'path/to/my/dir' };\nnrc.run(commands, options);\n```\n\n### Set different working directory for each command\n```javascript\nvar commands = [\n  { command: 'mkdir foo', cwd: 'dir1' },\n  { command: 'mkdir foo', cwd: 'dir2' }\n];\nnrc.run(commands);\n```\n\n### Set different working directory one command and default working directory for the others\n```javascript\nvar commands = [\n  'mkdir foo',\n  { command: 'mkdir foo', cwd: 'different/dir' },\n  'mkdir bar'\n];\nvar options = { cwd: 'default/dir' };\nnrc.run(commands, options);\n```\n\n### Run commands in parallel\n```javascript\nvar commands = [\n  './runCompute1.sh',\n  './runCompute2.sh',\n  './runCompute3.sh',\n];\nvar options = { mode: 'parallel' };\nnrc.run(commands, options);\n```\n\n## NRC Methods\n### Run\n#### Usage:\n```javsacript\nvar promise = nrc.run(commands, globalOptions);\n```\n#### Returns:\nA promise that resolves to an array of exit codes for commands run.\n#### Arguments:\n*`commands` can be specified in any one of the below formats*\n\n| name | type | required | description | example |\n|------|------|----------|-------------|---------|\n| commands | string | yes | The command to run | `'ls'` |\n| commands | array(string) | yes | An array of string commands to run | `['ls', 'mkdir foo']` |\n| commands | array(object) | yes | An array of objects describing commands to run. See section Options Object for allowed properties. | `[{ command: 'ls' }, { command: 'mkdir foo' }]` |\n| commands | array(object or string) | yes | A mixed array of objects describing commands and string commands to run. See section Options Object for allowed properties. | `[{ command: 'ls' }, 'mkdir foo']` |\n| globalOptions | object | no | The global options to set for each command being run. Overridden by command's options. | `{ cwd: 'foo', verbose: true, logger: gutil.log }` |\n\n## Options Object\nOptions available for the `commands` or `globalOptions` argument:\n\n| property | type | required | default | description |\n|----------|------|----------|---------|-------------|\n| command | string | yes | - | the command to run |\n| cwd | string | no | `process.cwd()` | the directory to run the command in |\n| onData | function(data) | no | null | where to send output from stdout. Called each time stdout is written. |\n| onError | function(data) | no | null | where to send output from stderr. Called each time stderr is written. |\n| onDone | function(code) | no | null | where to send the exit code of the command. Called once. |\n| verbose | boolean | no | `false` | show verbose output |\n| logger | function(data) | no | `console.log` | what function to use to log *when verbose is set to true* |\n| env | object | no | null | Environment key-value pairs\n| stdio | string or array | no | null | Child's stdio configuration\n| detached | boolean | no | null | Prepare child to run independently of its parent process. Specific behavior depends on the platform. |\n| uid | number | no | null | Sets the user identity of the process. |\n| gid | number | no | null | Sets the group identity of the process. |\n| shell | boolean or string | no | null | If true, runs command inside of a shell. Uses '/bin/sh' on UNIX, and 'cmd.exe' on Windows. A different shell can be specified as a string. The shell should understand the -c switch on UNIX, or /s /c on Windows. Defaults to false (no shell). |\n\n### Global-Only Commands\nThese options can only be set in the `globalOptions` argument.\n\n| property | type | required | default | description |\n|----------|------|----------|---------|-------------|\n| mode | string | no | `'sequential'` | Whether to run commands in series (sequentially) or in parallel. |\n","maintainers":[{"name":"c-h-","email":"charlie.hulcher@gmail.com"}],"time":{"modified":"2022-06-21T21:12:42.900Z","created":"2016-05-25T16:09:03.203Z","1.0.0":"2016-05-25T16:09:03.203Z","1.0.1":"2016-05-25T18:24:36.315Z"},"homepage":"https://github.com/c-h-/node-run-cmd#readme","keywords":["node","console","terminal","bash","command","shell"],"repository":{"type":"git","url":"git+https://github.com/c-h-/node-run-cmd.git"},"author":{"name":"Charlie Hulcher"},"bugs":{"url":"https://github.com/c-h-/node-run-cmd/issues"},"license":"MIT","readmeFilename":"README.md","users":{"anasqiblawi":true,"minazuki":true}}