-
Notifications
You must be signed in to change notification settings - Fork 4
/
update-module.js
39 lines (31 loc) · 1.08 KB
/
update-module.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
const fs = require('fs');
const path = require('path');
const version = process.argv[2];
if (!version) {
console.error('No version specified');
process.exit(1);
}
const moduleJsonPath = path.join(__dirname, 'module.json');
fs.readFile(moduleJsonPath, 'utf8', (err, data) => {
if (err) {
console.error(`Error reading module.json: ${err}`);
return;
}
let moduleJson;
try {
moduleJson = JSON.parse(data);
} catch (err) {
console.error(`Error parsing module.json: ${err}`);
return;
}
moduleJson.version = version;
moduleJson.manifest = `https://github.com/gambit07/gambits-premades/releases/latest/download/module.json`;
moduleJson.download = `https://github.com/gambit07/gambits-premades/releases/download/${version}/module.zip`;
fs.writeFile(moduleJsonPath, JSON.stringify(moduleJson, null, 2), 'utf8', (err) => {
if (err) {
console.error(`Error writing module.json: ${err}`);
return;
}
console.log(`module.json successfully updated to version ${version}`);
});
});