-
Notifications
You must be signed in to change notification settings - Fork 5
Expand file tree
/
Copy pathinstall.js
More file actions
58 lines (48 loc) · 1.48 KB
/
install.js
File metadata and controls
58 lines (48 loc) · 1.48 KB
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
// ==Headers==
// @Name: install
// @Description: install
// @Version: 1.0.62
// @Author: dodying
// @Modified: 2020-1-17 10:51:35
// @Namespace: https://github.com/dodying/Nodejs
// @SupportURL: https://github.com/dodying/Nodejs/issues
// @Require: fs-extra,readline-sync
// ==/Headers==
// 导入原生模块
const path = require('path');
// 导入第三方模块
const fse = require('fs-extra');
const readlineSync = require('readline-sync');
// Function
// Main
const main = async () => {
const args = process.argv.splice(2);
const install = require('./js/install_auto');
for (const file of args) {
const fullpath = path.resolve(process.cwd(), file);
if (!fse.existsSync(fullpath)) continue;
console.log(fullpath);
fse.emptyDirSync('./unzip');
const { dir, name } = path.parse(fullpath);
const topath = path.join(dir, name);
let topathTrue = topath;
let order = 1;
while (fse.existsSync(topathTrue)) {
topathTrue = topath + '-' + (order++);
}
await install({
output: fullpath,
parentPath: topathTrue,
path: path.resolve(topathTrue, name)
});
fse.emptyDirSync('./unzip');
}
readlineSync.keyInPause('Press any key to exit');
};
main().then(async () => {
//
}, async err => {
console.error(err);
readlineSync.keyInPause('Press any key to exit');
process.exit();
});