-
Notifications
You must be signed in to change notification settings - Fork 6
/
install.js
38 lines (33 loc) · 998 Bytes
/
install.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
/**
* Created by rokoroku on 2016-08-23.
*/
'use strict';
const fs = require('fs');
const url = require("url");
const path = require("path");
const wget = require('node-wget');
const dependencies = require('./package.json').mavenDependencies;
function clearPath(path) {
if (fs.existsSync(path)) {
fs.readdirSync(path).forEach(function (file, index) {
const curPath = path + "/" + file;
if (fs.lstatSync(curPath).isDirectory()) {
clearPath(curPath);
fs.rmdirSync(curPath);
} else {
fs.unlinkSync(curPath);
}
});
} else {
fs.mkdirSync(path);
}
}
function getDependencies(dependencies) {
for (const key in dependencies) {
const repository = dependencies[key];
const filename = path.basename(url.parse(repository).pathname);
wget({ url: repository, dest: 'jar/' + filename });
}
}
clearPath('./jar');
getDependencies(dependencies);