initial
This commit is contained in:
27
ecoos_daemon/ts/utils/command.ts
Normal file
27
ecoos_daemon/ts/utils/command.ts
Normal file
@@ -0,0 +1,27 @@
|
||||
/**
|
||||
* Shared command execution utility
|
||||
*/
|
||||
|
||||
export interface CommandResult {
|
||||
success: boolean;
|
||||
stdout: string;
|
||||
stderr: string;
|
||||
}
|
||||
|
||||
export async function runCommand(
|
||||
cmd: string,
|
||||
args: string[]
|
||||
): Promise<CommandResult> {
|
||||
const command = new Deno.Command(cmd, {
|
||||
args,
|
||||
stdout: 'piped',
|
||||
stderr: 'piped',
|
||||
});
|
||||
|
||||
const result = await command.output();
|
||||
return {
|
||||
success: result.success,
|
||||
stdout: new TextDecoder().decode(result.stdout),
|
||||
stderr: new TextDecoder().decode(result.stderr),
|
||||
};
|
||||
}
|
||||
Reference in New Issue
Block a user