1
0
Fork 0
mirror of https://github.com/denoland/deno.git synced 2024-12-22 07:14:47 -05:00

fix(tools): upgrade to new Deno.spawn api (#15265)

This commit is contained in:
Satya Rohith 2022-07-21 14:15:15 +05:30 committed by GitHub
parent f0e01682cc
commit e98e0da8b2
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
6 changed files with 24 additions and 24 deletions

View file

@ -3,14 +3,14 @@
import { join, ROOT_PATH as ROOT } from "./util.js";
async function bashOut(subcmd) {
const { status, stdout } = await Deno.spawn("bash", {
const { success, stdout } = await Deno.spawn("bash", {
args: ["-c", subcmd],
stdout: "piped",
stderr: "null",
});
// Check for failure
if (!status.success) {
if (!success) {
throw new Error("subcmd failed");
}
// Gather output
@ -20,7 +20,7 @@ async function bashOut(subcmd) {
}
async function bashThrough(subcmd, opts = {}) {
const { status } = await Deno.spawn("bash", {
const { success, code } = await Deno.spawn("bash", {
...opts,
args: ["-c", subcmd],
stdout: "inherit",
@ -28,8 +28,8 @@ async function bashThrough(subcmd, opts = {}) {
});
// Exit process on failure
if (!status.success) {
Deno.exit(status.code);
if (!success) {
Deno.exit(code);
}
}

View file

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

View file

@ -40,12 +40,12 @@ async function dlint() {
const chunks = splitToChunks(sourceFiles, `${execPath} run`.length);
for (const chunk of chunks) {
const { status } = await Deno.spawn(execPath, {
const { success } = await Deno.spawn(execPath, {
args: ["run", "--config=" + configFile, ...chunk],
stdout: "inherit",
stderr: "inherit",
});
if (!status.success) {
if (!success) {
throw new Error("dlint failed");
}
}
@ -71,12 +71,12 @@ async function dlintPreferPrimordials() {
const chunks = splitToChunks(sourceFiles, `${execPath} run`.length);
for (const chunk of chunks) {
const { status } = await Deno.spawn(execPath, {
const { success } = await Deno.spawn(execPath, {
args: ["run", "--rule", "prefer-primordials", ...chunk],
stdout: "inherit",
stderr: "inherit",
});
if (!status.success) {
if (!success) {
throw new Error("prefer-primordials failed");
}
}
@ -108,7 +108,7 @@ async function clippy() {
cmd.push("--release");
}
const { status } = await Deno.spawn("cargo", {
const { success } = await Deno.spawn("cargo", {
args: [
...cmd,
"--",
@ -124,7 +124,7 @@ async function clippy() {
stdout: "inherit",
stderr: "inherit",
});
if (!status.success) {
if (!success) {
throw new Error("clippy failed");
}
}

View file

@ -14,12 +14,12 @@ export { delay } from "../test_util/std/async/delay.ts";
export const ROOT_PATH = dirname(dirname(fromFileUrl(import.meta.url)));
async function getFilesFromGit(baseDir, args) {
const { status, stdout } = await Deno.spawn("git", {
const { success, stdout } = await Deno.spawn("git", {
stderr: "inherit",
args,
});
const output = new TextDecoder().decode(stdout);
if (!status.success) {
if (!success) {
throw new Error("gitLsFiles failed");
}

View file

@ -9,7 +9,7 @@ const V_WGPU = "0.13";
const TARGET_DIR = join(ROOT_PATH, "ext", "webgpu");
async function bash(subcmd, opts = {}) {
const { status } = await Deno.spawn("bash", {
const { success, code } = await Deno.spawn("bash", {
...opts,
args: ["-c", subcmd],
stdout: "inherit",
@ -17,8 +17,8 @@ async function bash(subcmd, opts = {}) {
});
// Exit process on failure
if (!status.success) {
Deno.exit(status.code);
if (!success) {
Deno.exit(code);
}
}

View file

@ -133,10 +133,10 @@ export function runPy<T extends Omit<Deno.SpawnOptions, "cwd">>(
}
export async function checkPy3Available() {
const { status, stdout } = await runPy(["--version"], {
const { success, stdout } = await runPy(["--version"], {
stdout: "piped",
}).output();
assert(status.success, "failed to run python --version");
assert(success, "failed to run python --version");
const output = new TextDecoder().decode(stdout);
assert(
output.includes("Python 3."),
@ -148,13 +148,13 @@ export async function checkPy3Available() {
export async function cargoBuild() {
if (binary) return;
const { status } = await Deno.spawn("cargo", {
const { success } = await Deno.spawn("cargo", {
args: ["build", ...(release ? ["--release"] : [])],
cwd: ROOT_PATH,
stdout: "inherit",
stderr: "inherit",
});
assert(status.success, "cargo build failed");
assert(success, "cargo build failed");
}
export function escapeLoneSurrogates(input: string): string;