forked from cadecairos/webmaker-suite
/
reset-webmaker.js
executable file
·41 lines (35 loc) · 1.04 KB
/
reset-webmaker.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
console.log("\n=======================================");
console.log("Resetting all apps in the Webmaker suite");
console.log("=======================================");
/**
* Runtime argument parsing
*/
function getRunTime() {
var argv = require("argv");
return argv.run().options;
}
var fs = require("fs"),
npm = require("./lib/commandstrings"),
repos = require("./lib/repos")(npm),
batchExec = require("./lib/batch").batchExec,
reset = [];
if(process.argv.indexOf("--fetch")>-1) {
reset.push("git fetch mozilla");
}
reset.push("git checkout -B master mozilla/master -f");
function updateRepos(repositories) {
if (repositories.length === 0) {
console.log("Finished updating all repositories.");
process.exit(0);
}
var appName = repositories.splice(0,1)[0],
app = repos[appName];
commands = reset.slice();
console.log("\n[" + appName + "]");
process.chdir(appName);
batchExec(commands, function() {
process.chdir("..");
updateRepos(repositories);
});
}
updateRepos(Object.keys(repos));