mirror of
https://github.com/denoland/deno.git
synced 2025-08-04 02:48:24 +00:00
refactor: use spawn API across codebase (#14414)
This commit is contained in:
parent
5ad8919d64
commit
4e1ca1d178
25 changed files with 266 additions and 327 deletions
|
@ -31,17 +31,13 @@ export function pathToAbsoluteFileUrl(path: string): URL {
|
|||
const decoder = new TextDecoder();
|
||||
|
||||
export async function execCode(code: string): Promise<[number, string]> {
|
||||
const p = Deno.run({
|
||||
cmd: [
|
||||
Deno.execPath(),
|
||||
const { status, stdout } = await Deno.spawn(Deno.execPath(), {
|
||||
args: [
|
||||
"eval",
|
||||
"--unstable",
|
||||
"--no-check",
|
||||
code,
|
||||
],
|
||||
stdout: "piped",
|
||||
});
|
||||
const [status, output] = await Promise.all([p.status(), p.output()]);
|
||||
p.close();
|
||||
return [status.code, decoder.decode(output)];
|
||||
return [status.code, decoder.decode(stdout)];
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue