Skip to content

Commit

Permalink
chore(cli): resolve version on-demand
Browse files Browse the repository at this point in the history
  • Loading branch information
hasundue committed Oct 23, 2023
1 parent ab9c657 commit d1ba3cf
Showing 1 changed file with 9 additions and 5 deletions.
14 changes: 9 additions & 5 deletions cli.ts
Original file line number Diff line number Diff line change
Expand Up @@ -11,10 +11,6 @@ import { GitCommitSequence } from "./lib/git.ts";
import { parseSemVer } from "./lib/semver.ts";
import { resolveLatestSemVer } from "./lib/dependency.ts";

const VERSION = parseSemVer(import.meta.url) ??
await resolveLatestSemVer(new URL("https://deno.land/x/molt@0.0.0/cli.ts")) ??
"undefined";

const { gray, yellow, bold, cyan } = colors;

const checkCommand = new Command()
Expand Down Expand Up @@ -330,13 +326,21 @@ function _formatPrefix(prefix: string | undefined) {
return prefix ? prefix.trimEnd() + " " : "";
}

const _version = async () => {
return parseSemVer(import.meta.url) ??
await resolveLatestSemVer(
new URL("https://deno.land/x/molt@0.0.0/cli.ts"),
) ??
"undefined";
};

const main = new Command()
.name("molt")
.description("A tool for updating dependencies in Deno projects")
.action(function () {
this.showHelp();
})
.version(VERSION)
.version(await _version())
.command("check", checkCommand)
.command("update", updateCommand);

Expand Down

0 comments on commit d1ba3cf

Please sign in to comment.