mirror of
https://github.com/Devolutions/IronRDP.git
synced 2025-07-07 17:45:01 +00:00
34 lines
932 B
JavaScript
34 lines
932 B
JavaScript
import { spawn } from 'child_process';
|
|
|
|
const run = async (command, cwd) => {
|
|
try {
|
|
const buildCommand = spawn(command, {
|
|
stdio: 'pipe',
|
|
shell: true,
|
|
cwd: cwd,
|
|
});
|
|
|
|
buildCommand.stdout.on('data', (data) => {
|
|
console.log(`${data}`);
|
|
});
|
|
|
|
buildCommand.stderr.on('data', (data) => {
|
|
console.error(`${data}`);
|
|
});
|
|
|
|
const exitCode = await new Promise((resolve, reject) => {
|
|
buildCommand.on('close', (code) => {
|
|
if (code !== 0) {
|
|
reject(new Error(`Process exited with non-zero code: ${code}`));
|
|
}
|
|
resolve(code);
|
|
});
|
|
});
|
|
|
|
console.log(`Child process exited with code: ${exitCode}`);
|
|
} catch (err) {
|
|
console.error(`Process run failed: ${err}`);
|
|
}
|
|
};
|
|
|
|
await run('cargo xtask web build', '../../');
|