From 4e1ca1d1787f25ab9f0a72ccf9d8028f70b3a7ed Mon Sep 17 00:00:00 2001 From: Leo Kettmeir Date: Wed, 18 May 2022 22:00:11 +0200 Subject: refactor: use spawn API across codebase (#14414) --- tools/format.js | 22 ++++++++++------------ 1 file changed, 10 insertions(+), 12 deletions(-) (limited to 'tools/format.js') diff --git a/tools/format.js b/tools/format.js index a829c86dd..2cd90f622 100755 --- a/tools/format.js +++ b/tools/format.js @@ -5,14 +5,14 @@ import { getPrebuiltToolPath, join, ROOT_PATH } from "./util.js"; async function dprint() { const configFile = join(ROOT_PATH, ".dprint.json"); const execPath = getPrebuiltToolPath("dprint"); - const p = Deno.run({ - cmd: [execPath, "fmt", "--config=" + configFile], + const { status } = await Deno.spawn(execPath, { + args: ["fmt", "--config=" + configFile], + stdout: "inherit", + stderr: "inherit", }); - const { success } = await p.status(); - if (!success) { + if (!status.success) { throw new Error("dprint failed"); } - p.close(); } async function main() { @@ -20,17 +20,15 @@ async function main() { await dprint(); if (Deno.args.includes("--check")) { - const git = Deno.run({ - cmd: ["git", "status", "-uno", "--porcelain", "--ignore-submodules"], - stdout: "piped", + const { status, stdout } = await Deno.spawn("git", { + args: ["status", "-uno", "--porcelain", "--ignore-submodules"], + stderr: "inherit", }); - const { success } = await git.status(); - if (!success) { + if (!status.success) { throw new Error("git status failed"); } - const out = new TextDecoder().decode(await git.output()); - git.close(); + const out = new TextDecoder().decode(stdout); if (out) { console.log("run tools/format.js"); -- cgit v1.2.3