mirror of
https://github.com/keymanapp/keyman.git
synced 2026-08-21 15:57:42 +00:00
This prepares a PR with updated history and version for auto-merge. Any new PRs are merged into HISTORY.md but existing entries are left untouched. Thus, we can tweak wording in HISTORY.md at any time without the effort of figuring out which PRs need to be present manually.
27 lines
658 B
TypeScript
27 lines
658 B
TypeScript
import { spawn } from 'child_process';
|
|
|
|
export const spawnChild = async function(cmd: string, params: string[]) {
|
|
const child = spawn(cmd, params);
|
|
|
|
let data = "";
|
|
for await (const chunk of child.stdout) {
|
|
//console.log('stdout chunk: '+chunk);
|
|
data += chunk;
|
|
}
|
|
|
|
let error = "";
|
|
for await (const chunk of child.stderr) {
|
|
//console.error('stderr chunk: '+chunk);
|
|
error += chunk;
|
|
}
|
|
|
|
const exitCode = await new Promise( (resolve) => {
|
|
child.on('close', resolve);
|
|
});
|
|
|
|
if(exitCode) {
|
|
throw new Error(`subprocess error exit ${exitCode}, ${error}`);
|
|
}
|
|
|
|
return data;
|
|
}
|