refactor: remove deno.run (#1036)

Co-authored-by: Luca Casonato <hello@lcas.dev>
This commit is contained in:
Sylvain Cau
2023-03-10 04:57:16 +09:00
committed by GitHub
co-authored by Luca Casonato
parent 891503e77f
commit 7e72fa236c
6 changed files with 63 additions and 88 deletions
+7 -8
View File
@@ -134,24 +134,23 @@ const manifest = {
export default manifest;
`;
const proc = Deno.run({
cmd: [Deno.execPath(), "fmt", "-"],
const proc = new Deno.Command(Deno.execPath(), {
args: ["fmt", "-"],
stdin: "piped",
stdout: "piped",
stderr: "null",
});
}).spawn();
const raw = new ReadableStream({
start(controller) {
controller.enqueue(new TextEncoder().encode(output));
controller.close();
},
});
await raw.pipeTo(proc.stdin.writable);
const out = await proc.output();
await proc.status();
proc.close();
await raw.pipeTo(proc.stdin);
const { stdout } = await proc.output();
const manifestStr = new TextDecoder().decode(out);
const manifestStr = new TextDecoder().decode(stdout);
const manifestPath = join(directory, "./fresh.gen.ts");
await Deno.writeTextFile(manifestPath, manifestStr);