unity-builder/src/model/cli/remote-client/remote-client-system.ts

24 lines
756 B
TypeScript
Raw Normal View History

2021-12-26 00:32:00 +00:00
import { exec } from 'child_process';
2021-12-25 20:05:17 +00:00
import CloudRunnerLogger from '../../cloud-runner/services/cloud-runner-logger';
export class RemoteClientSystem {
public static async Run(command: string) {
2021-12-26 00:32:00 +00:00
return await new Promise<string>((promise) => {
2021-12-26 01:05:51 +00:00
let output = '';
2021-12-26 01:33:03 +00:00
const child = exec(command);
child.stdout?.on('data', function (data) {
const outputChunk = `${data}`;
2021-12-26 01:05:51 +00:00
CloudRunnerLogger.logRemoteCli(outputChunk);
output += outputChunk;
2021-12-26 01:08:40 +00:00
});
2021-12-26 01:33:03 +00:00
child.stderr?.on('data', function (data) {
CloudRunnerLogger.logRemoteCli(`[STD-ERROR] ${data}`);
});
2021-12-26 01:08:40 +00:00
child.on('close', function (code) {
2021-12-26 01:33:03 +00:00
CloudRunnerLogger.logRemoteCli(`${code} `);
2021-12-26 01:08:40 +00:00
promise(output);
2021-12-26 00:32:00 +00:00
});
});
2021-12-25 20:05:17 +00:00
}
}