Skip to content

Commit

Permalink
Documented jake.exec.
Browse files Browse the repository at this point in the history
  • Loading branch information
mde committed Feb 5, 2012
1 parent 9d21f87 commit 8ddbdaa
Show file tree
Hide file tree
Showing 2 changed files with 29 additions and 1 deletion.
2 changes: 1 addition & 1 deletion Jakefile
@@ -1,7 +1,7 @@

desc('Runs the Jake tests.');
task('test', function () {
cmds = [
var cmds = [
'node ./tests/parseargs.js'
, 'node ./tests/task_base.js'
, 'node ./tests/file_task.js'
Expand Down
28 changes: 28 additions & 0 deletions README.md
Expand Up @@ -384,6 +384,34 @@ Setting a value for -T/--tasks will filter the list by that value:

The list displayed will be all tasks whose namespace/name contain the filter-string.

### Running shell-commands with `jake.exec`

Since shelling out in Node is an asynchronous operation, Jake provides a utility
function for running a sequence of shell-commands. The `jake.exec` command takes
an array of shell-command strings, and a final callback to run after completing
them. Here's an example from Jake's Jakefile, that runs the tests:

desc('Runs the Jake tests.');
task('test', function () {
var cmds = [
'node ./tests/parseargs.js'
, 'node ./tests/task_base.js'
, 'node ./tests/file_task.js'
];
jake.exec(cmds, function () {
console.log('All tests passed.');
complete();
}, {stdout: true});
});

It also takes an optional options-object, where you can set `stdout` (print to
stdout, default false), `stderr` (print to stderr, default false), and
`breakOnError` (stop execution on error, default true).

This command doesn't pipe input between commands -- it's for simple execution.
If you need something more sophisticated, Procstreams
(<https://github.com/polotek/procstreams>) might be a good option.

### PackageTask

Jake's PackageTask programmically creates a set of tasks for packaging up your
Expand Down

0 comments on commit 8ddbdaa

Please sign in to comment.