mirror of
https://github.com/0rangebananaspy/authelia.git
synced 2024-09-14 22:47:21 +07:00
21 lines
479 B
TypeScript
21 lines
479 B
TypeScript
|
var spawn = require('child_process').spawn;
|
||
|
|
||
|
|
||
|
export function exec(command: string): Promise<void> {
|
||
|
return new Promise((resolve, reject) => {
|
||
|
const cmd = spawn(command, {
|
||
|
shell: true,
|
||
|
});
|
||
|
|
||
|
cmd.stdout.pipe(process.stdout);
|
||
|
cmd.stderr.pipe(process.stderr);
|
||
|
cmd.on('exit', (statusCode: number) => {
|
||
|
if (statusCode == 0) {
|
||
|
resolve();
|
||
|
return;
|
||
|
}
|
||
|
reject(new Error('Exited with status code ' + statusCode));
|
||
|
});
|
||
|
});
|
||
|
}
|