Use Deno.Command for upgrade
This commit is contained in:
parent
4904644464
commit
2a1438f95a
@ -3,28 +3,28 @@ import { version } from "../version.ts";
|
|||||||
export async function upgradeCommand() {
|
export async function upgradeCommand() {
|
||||||
console.log("Now going to attempt an upgrade...");
|
console.log("Now going to attempt an upgrade...");
|
||||||
|
|
||||||
const p = Deno.run({
|
const command = new Deno.Command("deno", {
|
||||||
cmd: ["deno", "cache", "--reload", Deno.mainModule],
|
args: ["cache", "--reload", Deno.mainModule],
|
||||||
|
stdout: "inherit",
|
||||||
|
stderr: "inherit",
|
||||||
});
|
});
|
||||||
const exitCode = await p.status();
|
const commandOutput = await command.output();
|
||||||
if (!exitCode.success) {
|
if (!commandOutput.success) {
|
||||||
console.error("Something went wrong there...");
|
console.error("Something went wrong there...");
|
||||||
Deno.exit(1);
|
Deno.exit(1);
|
||||||
}
|
}
|
||||||
console.log(
|
console.log(
|
||||||
"So, that's done. Now let's see if this actually did anything...",
|
"So, that's done. Now let's see if this actually did anything...",
|
||||||
);
|
);
|
||||||
const vp = Deno.run({
|
const vp = new Deno.Command("deno", {
|
||||||
cmd: ["deno", "run", "-A", "--unstable", Deno.mainModule, "version"],
|
args: ["run", "-A", "--unstable", Deno.mainModule, "version"],
|
||||||
stdout: "piped",
|
|
||||||
});
|
});
|
||||||
const versionStatus = await vp.status();
|
const versionStatus = await vp.output();
|
||||||
if (!versionStatus.success) {
|
if (!versionStatus.success) {
|
||||||
console.error("Could not run version command, something is wrong.");
|
console.error("Could not run version command, something is wrong.");
|
||||||
Deno.exit(1);
|
Deno.exit(1);
|
||||||
}
|
}
|
||||||
const rawVersion = await vp.output();
|
const newVersion = new TextDecoder().decode(versionStatus.stdout).trim();
|
||||||
const newVersion = new TextDecoder().decode(rawVersion).trim();
|
|
||||||
if (newVersion === version) {
|
if (newVersion === version) {
|
||||||
console.log(
|
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.`,
|
`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.`,
|
||||||
|
Loading…
Reference in New Issue
Block a user