-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathpush-workshop.js
More file actions
68 lines (58 loc) · 1.8 KB
/
push-workshop.js
File metadata and controls
68 lines (58 loc) · 1.8 KB
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
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
var async = require('async');
var path = require('path');
var fs = require('fs');
var push = require('./push-project').push;
var login = require('./push-project').login;
var account_file = path.join('accounts', 'test-accounts.txt');
var accounts = fs.readFileSync(account_file).toString().trim().split("\n");
var project_file = path.join('projects', 'projects.txt');
var projects = fs.readFileSync(project_file).toString().trim().split("\n");
var separator = '---------------------------------------';
// do it
push_workshop(accounts, projects);
// pushing projects in synchronous order (because we can)
function push_workshop(accounts, projects) {
comboSeries(accounts, projects, login, push, {
intro: function() {
console.log(separator);
},
outerIntro: function(username) {
console.log('pushing projects for', username);
console.log(separator);
},
innerIntro: function(username, projectId) {
console.log('pushing project', projectId);
},
innerOutro: function(username, projectId) {
console.log('done pushing project');
},
outerOutro: function(username) {
console.log('done pushing', username);
console.log(separator);
},
outro: function() {
console.log('done.');
}
});
}
// synchronous cross-product function application
// with inter-woven callback functions ...
function comboSeries(a1, a2, fn1, fn2, cb, c1) {
cb.intro();
async.forEachSeries(a1, function(e1, callback) {
cb.outerIntro(e1);
fn1(e1, c1, function(c2) {
async.forEachSeries(a2, function(e2, callback) {
cb.innerIntro(e1, e2);
fn2(e1, e2, c2, function() {
cb.innerOutro(e1, e2);
callback();
});
}, function () {
cb.outerOutro(e1);
callback();
} );
});
},
cb.outro);
}