-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathindex.js
86 lines (76 loc) · 3.62 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
85
86
#!/usr/bin/env node
"use strict";
/**
* @author: Predrag Stojadinovic <[email protected]>
*
* Usage:
* -h, --help output usage information
* -V, --version output the version number
*
* -n, --npm Perform *only* npm calls
* -b, --bower Perform *only* bower calls
*
* -i, --install Perform *only* install calls
* -u, --update Perform *only* update calls
* -p, --prune Perform *only* prune calls
*
* -r, --recursive Perform calls recursively in all subfolders
* WARNING: The more projects you have, the longer it will take.
*
* -P, --parallel Perform npm and bower calls in parallel, not consecutively
* WARNING: The output will happen in real time, all mixed up.
* -f, --buffered Buffered output for the parallel execution
* WARNING: The output will happen only at the end:
* - once for all npm calls, and once for all bower calls.
*
* <no params> Same as using -nbiup:
* Performs all npm and bower install/update/prune calls in local project
*/
const commander = require("commander");
commander
.version("0.3.2")
.option("", "")
.option("-n, --npm", "Perform *only* npm calls", false)
.option("-b, --bower", "Perform *only* bower calls", false)
.option("", "")
.option("-i, --install", "Perform *only* install calls", false)
.option("-u, --update", "Perform *only* update calls", false)
.option("-p, --prune", "Perform *only* prune calls", false)
.option("", "")
.option("-r, --recursive", "Perform calls recursively in all subfolders", false)
.option("", "WARNING: The more projects you have, the longer it will take.")
.option("", "")
.option("-P, --parallel", "Perform npm and bower calls in parallel, not consecutively", false)
.option("", "WARNING: The output will happen in real time, all mixed up.")
.option("-f, --buffered", "Buffered output for the parallel execution", false)
.option("", "WARNING: The output will happen only at the end:")
.option("", "- once for all npm calls, and once for all bower calls.")
.option("", "")
.option("<no params>", "Same as using -nbiup:")
.option("", "Performs all npm and bower install/update/prune calls in local project")
.parse(process.argv);
commander.npm = true === commander.npm;
commander.bower = true === commander.bower;
commander.install = true === commander.install;
commander.update = true === commander.update;
commander.prune = true === commander.prune;
commander.recursive = true === commander.recursive;
commander.parallel = true === commander.parallel;
commander.buffered = true === commander.buffered;
// If just `update` is executed, run both npm and bower, and run all three iup calls
if (!commander.npm && !commander.bower) commander.npm = commander.bower = true;
if (!commander.install && !commander.update && !commander.prune) commander.install = commander.update = commander.prune = true;
if (commander.parallel && (commander.npm !== commander.bower)) {
console.log(("Ignoring -P (--parallel) because you only selected " + (commander.npm ? "npm" : "bower") + ".").red);
commander.parallel = false;
}
// commander debug:
// console.log("commander.npm: " + commander.npm);
// console.log("commander.bower: " + commander.bower);
// console.log("commander.install: " + commander.install);
// console.log("commander.update: " + commander.update);
// console.log("commander.prune: " + commander.prune);
// console.log("commander.recursive: " + commander.recursive);
// console.log("commander.parallel: " + commander.parallel);
// console.log("commander.buffered: " + commander.buffered);
require("./lib/updatejs").update(commander);