From 2a1438f95a5458f1bb4c3177184503f38d789a4a Mon Sep 17 00:00:00 2001 From: Zef Hemel Date: Wed, 4 Oct 2023 10:47:52 +0200 Subject: [PATCH] Use Deno.Command for upgrade --- cmd/upgrade.ts | 20 ++++++++++---------- 1 file changed, 10 insertions(+), 10 deletions(-) diff --git a/cmd/upgrade.ts b/cmd/upgrade.ts index d8207cd..a8be25c 100644 --- a/cmd/upgrade.ts +++ b/cmd/upgrade.ts @@ -3,28 +3,28 @@ import { version } from "../version.ts"; export async function upgradeCommand() { console.log("Now going to attempt an upgrade..."); - const p = Deno.run({ - cmd: ["deno", "cache", "--reload", Deno.mainModule], + const command = new Deno.Command("deno", { + args: ["cache", "--reload", Deno.mainModule], + stdout: "inherit", + stderr: "inherit", }); - const exitCode = await p.status(); - if (!exitCode.success) { + const commandOutput = await command.output(); + if (!commandOutput.success) { console.error("Something went wrong there..."); Deno.exit(1); } console.log( "So, that's done. Now let's see if this actually did anything...", ); - const vp = Deno.run({ - cmd: ["deno", "run", "-A", "--unstable", Deno.mainModule, "version"], - stdout: "piped", + const vp = new Deno.Command("deno", { + args: ["run", "-A", "--unstable", Deno.mainModule, "version"], }); - const versionStatus = await vp.status(); + const versionStatus = await vp.output(); if (!versionStatus.success) { console.error("Could not run version command, something is wrong."); Deno.exit(1); } - const rawVersion = await vp.output(); - const newVersion = new TextDecoder().decode(rawVersion).trim(); + const newVersion = new TextDecoder().decode(versionStatus.stdout).trim(); if (newVersion === version) { console.log( `Nope. I hate to tell you this, but it looks like we're still running ${newVersion}. This was a bit of a futile exercise. Let's try again soon some time.`,