-
Notifications
You must be signed in to change notification settings - Fork 1
/
index.js
126 lines (108 loc) · 2.55 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
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
'use strict';
const versionCheck = require('./lib/version-check');
const fileLoad = require('./lib/load-file');
const download = require('./lib/download');
const unpack = require('./lib/unpack');
exports.versionCheck = versionCheck;
exports.fileLoad = fileLoad;
exports.download = download;
exports.unpack = unpack;
/*const update = require('./lib/update');
const finishUpdate = require('./lib/finish-update');
const mode = process.argv[2];
const processCheck = options => {
versionCheck(options, (err, newVersion) => {
if (err) {
process.stdout.write(`!check@${err}\n`);
return;
}
process.stdout.write(`$check@${newVersion}\n`);
});
};
const processDownload = options => {
download(
options,
progress => {
process.stdout.write(`$download-progress@${progress}\n`);
},
err => {
if (err) {
process.stdout.write(`!download@${err}\n`);
return;
}
process.stdout.write(`$download@\n`);
});
};
const processUnpack = options => {
unpack(options,
progress => {
process.stdout.write(`$unpack-progress@${progress}\n`);
},
err => {
if (err) {
process.stdout.write(`!unpack@${err}\n`);
return;
}
process.stdout.write(`$unpack@\n`);
});
};
const processUpdate = options => {
update(options,
err => {
if (err) {
process.stdout.write(`!update@${err}\n`);
return;
}
process.stdout.write(`$update@\n`);
});
};
const processFinishUpdate = options => {
finishUpdate(options,
err => {
if (err) {
process.stdout.write(`!finish@${err}\n`);
return;
}
process.stdout.write(`$finish@\n`);
});
};
if (mode === 'check') {
const url = process.argv[3];
const version = process.argv[4];
processCheck({url, version});
}
if (mode === 'download') {
const url = process.argv[3];
const version = process.argv[4];
const path = process.argv[5];
const file = process.argv[6];
if (url && version && file) {
processDownload({url, version, path, file});
}
}
if (mode === 'unpack') {
const directory = process.argv[3];
const file = process.argv[4];
if (directory && file) {
processUnpack({directory, file});
}
}
if (mode === 'update') {
const source = process.argv[3];
const target = process.argv[4];
const toDelete = process.argv[5];
const toRun = process.argv[6];
if (source && target && toDelete && toRun) {
processUpdate({source, target, toDelete, toRun});
}
}
if (mode === 'finish-update') {
const source = process.argv[3];
const target = process.argv[4];
const toDelete = process.argv[5];
const toRun = process.argv[6];
if (source && target && toDelete && toRun) {
processFinishUpdate({source, target, toDelete, toRun});
}
}
*/