summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorGeert-Jan Zwiers <geertjanzwiers@protonmail.com>2022-12-01 16:51:47 +0100
committerGitHub <noreply@github.com>2022-12-01 16:51:47 +0100
commit0a82f3c0e96cb0f176e98663d5eb8dc251b191d2 (patch)
tree2d1e1f916ddeb5bd8c240b1c837ffd75ed741127
parent824cb485c542305d16e0b9dcfda0ce4a06cf5038 (diff)
chore(tools): update deprecated commands in format and lint tool (#16864)
Updates tools/format.js and tools/lint.js from Deno.spawn to Deno.Command API.
-rwxr-xr-xtools/format.js13
-rwxr-xr-xtools/lint.js18
2 files changed, 21 insertions, 10 deletions
diff --git a/tools/format.js b/tools/format.js
index fe18352f3..b13159613 100755
--- a/tools/format.js
+++ b/tools/format.js
@@ -5,12 +5,15 @@ import { getPrebuiltToolPath, join, ROOT_PATH } from "./util.js";
async function dprint() {
const configFile = join(ROOT_PATH, ".dprint.json");
const execPath = getPrebuiltToolPath("dprint");
- const { success } = await Deno.spawn(execPath, {
+ const cmd = new Deno.Command(execPath, {
args: ["fmt", "--config=" + configFile],
stdout: "inherit",
stderr: "inherit",
});
- if (!success) {
+
+ const { code } = await cmd.output();
+
+ if (code > 0) {
throw new Error("dprint failed");
}
}
@@ -20,12 +23,14 @@ async function main() {
await dprint();
if (Deno.args.includes("--check")) {
- const { success, stdout } = await Deno.spawn("git", {
+ const cmd = new Deno.Command("git", {
args: ["status", "-uno", "--porcelain", "--ignore-submodules"],
stderr: "inherit",
});
- if (!success) {
+ const { code, stdout } = await cmd.output();
+
+ if (code > 0) {
throw new Error("git status failed");
}
const out = new TextDecoder().decode(stdout);
diff --git a/tools/lint.js b/tools/lint.js
index a9279bb25..baa1e9c3c 100755
--- a/tools/lint.js
+++ b/tools/lint.js
@@ -43,12 +43,14 @@ async function dlint() {
const chunks = splitToChunks(sourceFiles, `${execPath} run`.length);
for (const chunk of chunks) {
- const { success } = await Deno.spawn(execPath, {
+ const cmd = new Deno.Command(execPath, {
args: ["run", "--config=" + configFile, ...chunk],
stdout: "inherit",
stderr: "inherit",
});
- if (!success) {
+ const { code } = await cmd.output();
+
+ if (code > 0) {
throw new Error("dlint failed");
}
}
@@ -74,12 +76,14 @@ async function dlintPreferPrimordials() {
const chunks = splitToChunks(sourceFiles, `${execPath} run`.length);
for (const chunk of chunks) {
- const { success } = await Deno.spawn(execPath, {
+ const cmd = new Deno.Command(execPath, {
args: ["run", "--rule", "prefer-primordials", ...chunk],
stdout: "inherit",
stderr: "inherit",
});
- if (!success) {
+ const { code } = await cmd.output();
+
+ if (code > 0) {
throw new Error("prefer-primordials failed");
}
}
@@ -111,7 +115,7 @@ async function clippy() {
cmd.push("--release");
}
- const { success } = await Deno.spawn("cargo", {
+ const cargoCmd = new Deno.Command("cargo", {
args: [
...cmd,
"--",
@@ -121,7 +125,9 @@ async function clippy() {
stdout: "inherit",
stderr: "inherit",
});
- if (!success) {
+ const { code } = await cargoCmd.output();
+
+ if (code > 0) {
throw new Error("clippy failed");
}
}