1
0
Fork 0
mirror of https://github.com/denoland/deno.git synced 2024-11-25 15:29:32 -05:00

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.
This commit is contained in:
Geert-Jan Zwiers 2022-12-01 16:51:47 +01:00 committed by GitHub
parent 824cb485c5
commit 0a82f3c0e9
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
2 changed files with 21 additions and 10 deletions

View file

@ -5,12 +5,15 @@ import { getPrebuiltToolPath, join, ROOT_PATH } from "./util.js";
async function dprint() { async function dprint() {
const configFile = join(ROOT_PATH, ".dprint.json"); const configFile = join(ROOT_PATH, ".dprint.json");
const execPath = getPrebuiltToolPath("dprint"); const execPath = getPrebuiltToolPath("dprint");
const { success } = await Deno.spawn(execPath, { const cmd = new Deno.Command(execPath, {
args: ["fmt", "--config=" + configFile], args: ["fmt", "--config=" + configFile],
stdout: "inherit", stdout: "inherit",
stderr: "inherit", stderr: "inherit",
}); });
if (!success) {
const { code } = await cmd.output();
if (code > 0) {
throw new Error("dprint failed"); throw new Error("dprint failed");
} }
} }
@ -20,12 +23,14 @@ async function main() {
await dprint(); await dprint();
if (Deno.args.includes("--check")) { if (Deno.args.includes("--check")) {
const { success, stdout } = await Deno.spawn("git", { const cmd = new Deno.Command("git", {
args: ["status", "-uno", "--porcelain", "--ignore-submodules"], args: ["status", "-uno", "--porcelain", "--ignore-submodules"],
stderr: "inherit", stderr: "inherit",
}); });
if (!success) { const { code, stdout } = await cmd.output();
if (code > 0) {
throw new Error("git status failed"); throw new Error("git status failed");
} }
const out = new TextDecoder().decode(stdout); const out = new TextDecoder().decode(stdout);

View file

@ -43,12 +43,14 @@ async function dlint() {
const chunks = splitToChunks(sourceFiles, `${execPath} run`.length); const chunks = splitToChunks(sourceFiles, `${execPath} run`.length);
for (const chunk of chunks) { for (const chunk of chunks) {
const { success } = await Deno.spawn(execPath, { const cmd = new Deno.Command(execPath, {
args: ["run", "--config=" + configFile, ...chunk], args: ["run", "--config=" + configFile, ...chunk],
stdout: "inherit", stdout: "inherit",
stderr: "inherit", stderr: "inherit",
}); });
if (!success) { const { code } = await cmd.output();
if (code > 0) {
throw new Error("dlint failed"); throw new Error("dlint failed");
} }
} }
@ -74,12 +76,14 @@ async function dlintPreferPrimordials() {
const chunks = splitToChunks(sourceFiles, `${execPath} run`.length); const chunks = splitToChunks(sourceFiles, `${execPath} run`.length);
for (const chunk of chunks) { for (const chunk of chunks) {
const { success } = await Deno.spawn(execPath, { const cmd = new Deno.Command(execPath, {
args: ["run", "--rule", "prefer-primordials", ...chunk], args: ["run", "--rule", "prefer-primordials", ...chunk],
stdout: "inherit", stdout: "inherit",
stderr: "inherit", stderr: "inherit",
}); });
if (!success) { const { code } = await cmd.output();
if (code > 0) {
throw new Error("prefer-primordials failed"); throw new Error("prefer-primordials failed");
} }
} }
@ -111,7 +115,7 @@ async function clippy() {
cmd.push("--release"); cmd.push("--release");
} }
const { success } = await Deno.spawn("cargo", { const cargoCmd = new Deno.Command("cargo", {
args: [ args: [
...cmd, ...cmd,
"--", "--",
@ -121,7 +125,9 @@ async function clippy() {
stdout: "inherit", stdout: "inherit",
stderr: "inherit", stderr: "inherit",
}); });
if (!success) { const { code } = await cargoCmd.output();
if (code > 0) {
throw new Error("clippy failed"); throw new Error("clippy failed");
} }
} }