RSNewWebUI/webui-src/make-src/build.js
2026-08-03 01:06:46 +05:30

36 lines
1.1 KiB
JavaScript

'use strict';
const assert = require('node:assert/strict');
const path = require('node:path');
const { spawnSync } = require('node:child_process');
const shellScript = path.join(__dirname, 'build.sh');
const batchScript = path.join(__dirname, 'build.bat');
function getRunner(platform, commandShell = 'cmd.exe') {
return platform === 'win32'
? { command: commandShell, args: ['/d', '/c', batchScript] }
: { command: 'sh', args: [shellScript] };
}
function run(runner) {
const result = spawnSync(runner.command, runner.args, { stdio: 'inherit' });
if (result.error) {
console.error(result.error.message);
return 1;
}
return result.status ?? 1;
}
if (process.argv[2] === '--check') {
assert.equal(path.basename(getRunner('win32').args[2]), 'build.bat');
assert.equal(path.basename(getRunner('linux').args[0]), 'build.sh');
const status = process.platform === 'win32'
? 0
: run({ command: 'sh', args: ['-n', shellScript] });
if (status === 0) console.log('Build dispatcher checks passed.');
process.exitCode = status;
} else {
process.exitCode = run(getRunner(process.platform, process.env.ComSpec));
}