-
Notifications
You must be signed in to change notification settings - Fork 7
/
install-games.js
33 lines (30 loc) · 1.08 KB
/
install-games.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
const fs = require('fs');
const path = require('path');
const { spawn } = require('cross-spawn');
const { list } = require('./games');
async function run() {
const games = list();
for (game of games) {
const installScript = path.join(game.workingDir, 'install.sh');
if (fs.existsSync(installScript)) {
console.log(`Executing install script in ${game.workingDir}`);
const child = spawn('./install.sh', { cwd: game.workingDir, stdio: ['inherit', 'inherit', 'inherit'] });
await new Promise((resolve, reject) => {
child.on('exit', (code) => {
if (code === 0) {
console.log('Install script completed successfully');
} else {
console.error(`WARNING: Install script exited with code ${code}. ${game.title} will not be playable.`);
}
resolve();
})
});
}
}
}
run()
.then(() => process.exit(0))
.catch(err => {
console.error(err);
process.exit(1);
});