-
Notifications
You must be signed in to change notification settings - Fork 1
/
index.js
executable file
·85 lines (74 loc) · 2.21 KB
/
index.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
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
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
#!/usr/bin/env node
var fs = require('fs');
var git = require('gift');
var lineReader = require('@klortho/line-reader')
var mkdirp = require('mkdirp');
var rimraf = require('rimraf');
var dummy_repo = 'dummy-repo';
var readme = dummy_repo + "/README.md";
rimraf.sync(dummy_repo);
var emails = [];
var p = lineReader('users.txt', function(line) {
if (line != '') {
emails.push(line);
}
})
.then(
function() {
console.log("done");
return emails;
},
function(err) {
console.log('Error: ', err);
process.exit(1);
}
)
.then(
function(emails) {
console.log('emails: %o', emails);
mkdirp(dummy_repo, function(err) {
if (err) {
throw "Failed to make directory " + dummy_repo;
}
git.init(dummy_repo, function(err, repo) {
if (err) {
throw "Failed to initialize git repo"
}
fs.writeFile(readme, 'Initial line\n',
function (err) {
if (err) throw err;
console.log('Repo initialized');
emails.reduce(function(sequence, email) {
return sequence.then(function() {
console.log("Start sequence for " + email);
return new Promise(function(resolve, reject) {
console.log(" Appending to readme: " + email);
fs.appendFile(readme, "line\n", function(err) {
console.log(" git add readme: " + email);
repo.add("README.md", function(err) {
if (err) {
reject(err);
}
console.log(" git commit: " + email);
repo.commit("dummy commit by " + email,
{
author: "Dummy <" + email + ">"
},
function(err) {
console.log(" done: " + email);
if (err) reject(err);
else resolve();
});
});
});
});
});
}, Promise.resolve());
});
});
});
},
function(err) {
console.log("*** Error: " + err);
}
);