OpenAsar/scripts/testStartup.js

35 lines
817 B
JavaScript
Raw Normal View History

2022-02-01 20:54:35 +00:00
const { execFile } = require('child_process');
const test = () => {
2022-02-01 21:52:48 +00:00
console.log('running...');
const proc = execFile('xvfb-run', [process.argv[2], '--enable-logging']);
2022-02-01 20:54:35 +00:00
let success = false;
2022-02-01 21:52:48 +00:00
let anyOutput = false;
2022-02-01 20:54:35 +00:00
proc.stderr.on('data', (data) => {
console.error('stderr', data.toString());
2022-02-01 20:54:35 +00:00
});
proc.stdout.on('data', (data) => {
2022-02-01 21:52:48 +00:00
anyOutput = true;
console.log('stdout', data.toString());
if (data.toString().includes('Installing discord_rpc')) {
success = true;
setTimeout(() => proc.kill(), 1000);
}
});
2022-02-01 20:54:35 +00:00
proc.on('close', async () => {
2022-02-01 21:52:48 +00:00
if (!anyOutput) return;
2022-02-01 20:54:35 +00:00
process.exit(success ? 0 : 1);
});
2022-02-01 21:52:48 +00:00
setTimeout(() => {
if (anyOutput) return;
console.log('detected no output in 5s, retrying...');
proc.kill();
2022-02-01 21:53:44 +00:00
test();
2022-02-01 21:52:48 +00:00
}, 5000);
2022-02-01 20:54:35 +00:00
};
2022-02-01 21:53:44 +00:00
test();