-
Notifications
You must be signed in to change notification settings - Fork 2k
/
Copy pathupdate.js
executable file
·62 lines (49 loc) · 1.01 KB
/
update.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
#!/usr/bin/env node
'use strict';
const update = require('./updateLib');
const usage = `
Update the node docker images.
Usage:
./update.js [ OPTIONS ]
OPTIONS:
-h, --help\tthis message
-a, --all\tupdate all images even if no node version update`;
const printUsage = () => {
console.log(usage);
};
const runUpdate = async (updateAll) => {
const updated = await update(updateAll);
updated.forEach(({ file }) => {
console.log('Updated', file);
});
if (!updated.length) {
console.log('Nothing updated');
}
};
const main = async () => {
if (process.argv.length > 3) {
printUsage();
process.exit(1);
}
if (process.argv.length === 2) {
await runUpdate(false);
return;
}
switch (process.argv[2]) {
case '-a':
case '--all':
await runUpdate(true);
return;
case '-h':
case '--help':
printUsage();
return;
default:
printUsage();
process.exit(1);
}
};
main().catch((e) => {
console.error(e);
process.exit(1);
});