-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathglobal.js
77 lines (69 loc) · 2.65 KB
/
global.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
var colors = require("colors");
var co = require("co");
var jobs = {};
var result = {};
var module_path = __dirname;
require("shelljs/global");
process.on('exit', function(code) {
//console.log(code);
});
process.on('uncaughtException', function(code) {
console.log(code);
});
// =========== [ job.index() ] ===========
jobs.index = co.wrap(function*() {
try {
// =========== [ get params from user input ] ===========
var argv2 = process.argv[2] || "help";
// =========== [ getCommonTasks ] ===========
if (['getCommonTasks','gct'].indexOf(argv2) > -1) {
var task = require("./tasks/getCommonTasks/index.js");
yield task.start();
}
// automatically add tasks here
// =========== [ configGet ] ===========
else if (['configGet','cg'].indexOf(argv2) > -1) {
var task = require("./tasks/configGet/index.js");
task.start();
}
// =========== [ init ] ===========
else if (["init", "-init", "i", "-i"].indexOf(argv2) > -1) {
var task = require("./tasks/init/index.js");
task.run();
}
// =========== [ install global ] ===========
else if (["installGlobal", "-g", "g", "global"].indexOf(argv2) > -1) {
var task = require("./tasks/installGlobal/index.js");
yield task.run(result);
}
// =========== [ link modules to node_modules ] ===========
else if (["linkNode", "node", "ln", "-ln"].indexOf(argv2) > -1) {
var task = require("./tasks/linkNodeModules/index.js");
yield task.start(module_path);
}
// =========== [ publishFolder ] ===========
else if (['publishFolder','pubFol', 'pf', '-pf'].indexOf(argv2) > -1) {
var task = require("./tasks/publishFolder/index.js");
yield task.start();
}
// =========== [ reininit] ===========
else if (["reinit", "-reinit"].indexOf(argv2) > -1) {
var task = require("./tasks/reinit/index.js");
yield task.start(module_path);
}
// =========== [ reinstall ] ===========
else if (["reinstall", "-reinstall"].indexOf(argv2) > -1) {
var task = require("./tasks/reinstall/index.js");
yield task.start();
}
// =========== [ getCommonTasks ] ===========
else {
require("dm-npm").getCommonTasks(argv2, __dirname);
}
} catch (e) {
console.log("Filename: ", __filename, "\n", e.stack);
}
return Promise.resolve(result);
}); // job.index()
// =========== [ MODULE EXPORT ] ===========
module.exports = jobs;