-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathrun
executable file
·54 lines (44 loc) · 1.27 KB
/
run
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
#!/usr/bin/env node
const { spawn } = require('child_process');
async function command(command, args = []) {
const childProcess = spawn(command, args, {
stdio: 'inherit'
});
return new Promise((resolve, reject) => {
childProcess.on('error', reject);
childProcess.on('close', (code) => {
if (code === 0) resolve();
else reject(new Error(`Command failed with code ${code}`));
});
});
}
// Example usage with async/await
async function main() {
process.chdir(__dirname);
let rawArgs = process.argv.slice(2);
let haxeBuildArgs = ['build.hxml'];
let lorelineArgs = [];
let i = 0;
while (i < rawArgs.length) {
if (rawArgs[i].startsWith('-D')) {
haxeBuildArgs.push('-D');
haxeBuildArgs.push(rawArgs[i].substring(2));
}
else if (rawArgs[i] == '--debug') {
haxeBuildArgs.push('--debug');
}
else {
lorelineArgs.push(rawArgs[i]);
}
i++;
}
await command('haxe', ['--neko', 'run.n'].concat(haxeBuildArgs));
await command('neko', ['run.n'].concat(lorelineArgs).concat([__dirname]));
}
(async () => {
try {
await main();
} catch (error) {
console.error(error);
}
})();