Comparing version 0.2.1 to 0.2.2
{ | ||
"name": "executive", | ||
"version": "0.2.1", | ||
"version": "0.2.2", | ||
"description": "exec for the lazy", | ||
@@ -5,0 +5,0 @@ "main": "index.js", |
@@ -5,3 +5,3 @@ # executive | ||
## Examples | ||
## Usage | ||
@@ -16,2 +16,11 @@ ```javascript | ||
Arguments are parsed out properly for you: | ||
```javascript | ||
var exec = require('executive'); | ||
exec('ls -AGF Foo\\ bar', function(err, out, code) { | ||
// Note the escaped folder name. | ||
}); | ||
``` | ||
Also supports simple serial execution of commands: | ||
@@ -26,37 +35,54 @@ ```javascript | ||
Arguments are parsed out properly for you: | ||
In the case of a failure, no additional commands will be executed: | ||
```javascript | ||
var exec = require('executive'); | ||
exec('ls -AGF Foo\\ bar', function(err, out, code) { | ||
// Note the escaped folder name. | ||
exec(['ls', 'aaaaa', 'ls'], function(err, out, code) { | ||
// First command succeeds, second blows up, third is never called. | ||
}); | ||
``` | ||
If you'd prefer not to pipe `stdin`, `stdout`, `stderr`: | ||
## Options | ||
Options may be passed as the second argument to exec and in the case of `quiet` | ||
and `interactive` helper functions exist. | ||
```javascript | ||
var exec = require('executive'); | ||
exec('ls', {options: quiet}) | ||
``` | ||
exec(['ls', 'ls'], {quiet: true}, function(err, out, code) { | ||
// Not a peep is heard, and both ls commands will be executed. | ||
}); | ||
and | ||
```javascript | ||
exec.quiet('ls') | ||
``` | ||
...or slightly more succint: | ||
are equivalent. | ||
#### options.interactive | exec.interactive | ||
##### default `false` | ||
If you need to interact with a program (your favorite text editor for instance) | ||
or watch the output of a long running process (`tail -f`), or just don't care | ||
about checking `stderr` and `stdout`, set `interactive` to `true`: | ||
```javascript | ||
exec.quiet(['ls', 'ls'], function(err, out, code) { | ||
// both commands executed | ||
exec.interactive('vim', function(err, out, code) { | ||
// Edit your commit message or whatnot | ||
}); | ||
``` | ||
In the case of a failure, no additional commands will be executed: | ||
#### options.quiet | exec.quiet | ||
##### default `false` | ||
If you'd prefer not to pipe `stdin`, `stdout`, `stderr` set `quiet` to `false`: | ||
```javascript | ||
exec(['ls', 'aaaaa', 'ls'], function(err, out, code) { | ||
// Only the first command succeeds, the last is never called. | ||
exec.quiet(['ls', 'ls'], function(err, out, code) { | ||
// Not a peep is heard, and both ls commands will be executed. | ||
}); | ||
``` | ||
...but you can also choose to ignore errors: | ||
#### options.safe | ||
##### default `true` | ||
In case you need to ignore errors during serial execution it's possible to set | ||
`safe` to `false`: | ||
```javascript | ||
@@ -68,10 +94,6 @@ exec(['ls', 'aaaaaa', 'ls'], {safe: false}, function(err, out, code) { | ||
If you need to interact with a program, for instance vim, use interactive mode: | ||
```javascript | ||
exec.interactive('vim', function(err) { | ||
// Edit your commit message or whatnot | ||
}); | ||
``` | ||
## Extra credit | ||
The spawned child process object is accessible when you exec a single program | ||
(not available when using the simple serial execution wrapper): | ||
You even do whatever you want with the child process object: | ||
```javascript | ||
@@ -82,3 +104,3 @@ var exec = require('executive'); | ||
child.stdout.on('data', function(data) { | ||
console.log(data.toString()); | ||
// Do your own thing | ||
}); | ||
@@ -85,0 +107,0 @@ ``` |
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
8397
120