import { log } from "../deps.ts";export default async ( cmd: string, args: Array<string>, cwd?: string, dry = false,) => { const logger = log.getLogger(); if (dry) { logger.debug([`dry ${cwd} ${cmd}`, ...args].join(" ")); return Promise.resolve(""); } logger.debug([cwd, cmd, ...args].join(" ")); const p = new Deno.Command(cmd, { args, cwd, stdin: "piped", stdout: "piped", }); const child = p.spawn(); const status = await child.status; if (status.code === 0) { return Promise.resolve(); } else { throw new Error( `\n${Deno.cwd()} ${cwd} ${cmd} ${args}`, ); }};
const command = new Deno.Command(Deno.execPath(), { args: [ "eval", "console.log('hello'); console.error('world')", ],});const { code, stdout, stderr } = await command.output();