diff --git a/denon.ts b/denon.ts index 6554231..d916de2 100644 --- a/denon.ts +++ b/denon.ts @@ -11,6 +11,7 @@ import { printHelp, initializeConfig, grantPermissions, + upgrade, } from "./src/cli.ts"; import { readConfig, DenonConfig } from "./src/config.ts"; import { parseArgs } from "./src/args.ts"; @@ -113,18 +114,7 @@ if (import.meta.main) { // update denon to latest release if (args.upgrade) { - log.info( - "Running \`deno install -Af --unstable https://deno.land/x/denon/denon.ts\`", - ); - Deno.run({ - cmd: [ - "deno", - "install", - "-Af", - "--unstable", - "https://deno.land/x/denon/denon.ts", - ], - }); + await upgrade(); Deno.exit(0); } diff --git a/src/cli.ts b/src/cli.ts index 71b9c95..03a4dc7 100644 --- a/src/cli.ts +++ b/src/cli.ts @@ -73,6 +73,25 @@ export async function initializeConfig() { } } +/** + * Grab a fresh copy of denon + */ +export async function upgrade() { + log.info( + "Running \`deno install -Af --unstable https://deno.land/x/denon/denon.ts\`", + ); + await Deno.run({ + cmd: [ + "deno", + "install", + "-Af", + "--unstable", + "https://deno.land/x/denon/denon.ts", + ], + }).status(); + Deno.exit(0); +} + /** * List all available scripts declared in the config file. * // TODO: make it interactive