-
Notifications
You must be signed in to change notification settings - Fork 15
/
Copy pathconfig-pack-installer.js
59 lines (52 loc) · 1.51 KB
/
config-pack-installer.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
(async function main() {
const fs = require('fs');
const path = require('path');
let filenames = fs.readdirSync(path.join(__dirname, 'minecloud_configs'));
packageFileName = '';
zipFileCount = 0;
filenames.forEach((file) => {
if (file.endsWith('.zip')) {
packageFileName = file;
zipFileCount++;
} else if (file.endsWith('.md')) {
// do nothing
} else {
fs.rmSync(path.join(__dirname, 'minecloud_configs', file), {
recursive: true,
force: true
});
}
});
if (zipFileCount == 0) {
console.error(
'No configuration package found. Have your placed the configuration package in the /minecloud_configs folder yet?'
);
return;
}
if (zipFileCount >= 2) {
console.error(
'More than 1 configuration packages were found. Make sure to only place 1 configuration package in the /minecloud_configs folder.'
);
return;
}
console.log('Installing MineCloud Configuration Package: ', packageFileName);
const extract = require('extract-zip');
await extract(path.join(__dirname, 'minecloud_configs', packageFileName), {
dir: path.join(__dirname, 'minecloud_configs')
});
if (
fs.existsSync(
path.join(__dirname, 'minecloud_configs', 'config-pack-info.json')
)
)
console.log(
'Successfully installed',
path.parse(packageFileName).name,
'configuration package.'
);
else
console.error(
'Failed to install config pack:',
'"config-pack-info.json" not found'
);
})();