-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathcontrol_flow_example.js
33 lines (31 loc) · 1.05 KB
/
control_flow_example.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
var flow = require('nimble')
, exec = require('child_process').exec;
function downloadNodeVersion (version, destination, callback) {
var url = 'http://nodejs.org/dist/node-v' + version + '.tar.gz';
var filepath = destination + '/' + version + '.tgz';
exec('curl ' + url + ' >' + filepath, callback);
}
flow.series([
function (callback) {
flow.parallel([
function (callback) {
console.log('Downloading Node v0.4.6...');
downloadNodeVersion('0.4.6', '/tmp', callback);
},
function (callback) {
console.log('Downloading Node v0.4.7...');
downloadNodeVersion('0.4.7', '/tmp', callback);
}
], callback);
},
function(callback) {
console.log('Creating archive of downloaded files...');
exec(
'tar cvf node_distros.tar /tmp/0.4.6.tgz /tmp/0.4.7.tgz',
function(error, stdout, stderr) {
console.log('All done!');
callback();
}
);
}
]);