-
Notifications
You must be signed in to change notification settings - Fork 17
/
Copy pathreadGameVersion.js
47 lines (39 loc) · 1.39 KB
/
readGameVersion.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
const os = require("os");
const fs = require("fs");
const util = require("util");
function setOutput(key, value) {
// Temporary hack until core actions library catches up with github new recommendations
const output = process.env['GITHUB_OUTPUT']
fs.appendFileSync(output, `${key}=${value}${os.EOL}`)
}
;(async () => {
// game/01-config/sugarcubeConfig.js
console.log('process.argv.length', process.argv.length);
console.log('process.argv', process.argv);
const GameSugarCubeConfigJsFilePath = process.argv[2];
console.log('GameSugarCubeConfigJsFilePath', GameSugarCubeConfigJsFilePath);
if (!GameSugarCubeConfigJsFilePath) {
console.error('no GameSugarCubeConfigJsFilePath');
process.exit(1);
return;
}
const GameSugarCubeConfigJsF = await (util.promisify(fs.readFile)(GameSugarCubeConfigJsFilePath, {encoding: 'utf-8'}));
const findR = RegExp(/version: {0,}"([^"]+)"/).exec(GameSugarCubeConfigJsF);
if (!findR) {
console.error('cannot find version reg');
process.exit(1);
return;
}
const version = findR[1];
if (!version) {
console.error('cannot find version string');
process.exit(1);
return;
}
console.log('GameVersionString:', version);
setOutput("GameVersionString", version);
process.exit(0);
})().catch(E => {
console.error(E);
process.exit(1);
});