RoXuS
RoXuS
DDeno
Created by RoXuS on 10/14/2023 in #help
Usage of Deno.Command?
thx for your response!
7 replies
DDeno
Created by RoXuS on 10/14/2023 in #help
Usage of Deno.Command?
yes finally I have try :
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}`,
);
}
};
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}`,
);
}
};
And it is ok, I don't understand why the result are piped to the log but it works haha
7 replies
DDeno
Created by RoXuS on 10/14/2023 in #help
Usage of Deno.Command?
No u can't use command.output with stdin to piped
7 replies
DDeno
Created by RoXuS on 10/14/2023 in #help
Usage of Deno.Command?
if I use the example of Deno.Command, something like
const command = new Deno.Command(Deno.execPath(), {
args: [
"eval",
"console.log('hello'); console.error('world')",
],
});
const { code, stdout, stderr } = await command.output();
const command = new Deno.Command(Deno.execPath(), {
args: [
"eval",
"console.log('hello'); console.error('world')",
],
});
const { code, stdout, stderr } = await command.output();
It works but I have the log after total execution, I would like the log as execution progresses
7 replies