Skip to content

Commit 2bdcc1a

Browse files
authored
Merge pull request #50 from pkgxdev/move-pkgx-version-check
Check pkgx version only when we need it
2 parents b968f81 + 8460ad8 commit 2bdcc1a

File tree

2 files changed

+8
-8
lines changed

2 files changed

+8
-8
lines changed

.github/workflows/cd.yml

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -43,7 +43,8 @@ jobs:
4343
mv pkgm.ts pkgm
4444
tar czf pkgm-$V.tgz pkgm
4545
46-
- uses: pkgxdev/setup@v2
46+
- uses: pkgxdev/setup@v3
47+
4748
- name: verify `pkgm --version`
4849
run: test "$(./pkgm --version)" = "pkgm $V"
4950

pkgm.ts

Lines changed: 6 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -13,13 +13,6 @@ import { ensureDir, existsSync, walk } from "jsr:@std/fs@^1";
1313
import { parseArgs } from "jsr:@std/cli@^1";
1414
import hydrate from "https://deno.land/x/libpkgx@v0.20.3/src/plumbing/hydrate.ts";
1515

16-
const out = new Deno.Command("pkgx", { args: ["--version"] }).outputSync();
17-
const match = new TextDecoder().decode(out.stdout).match(/pkgx 2.(\d+)/);
18-
if (!match || parseInt(match[1]) < 4) {
19-
console.error("pkgm requires pkgx 2.4.0 or later");
20-
Deno.exit(1);
21-
}
22-
2316
function standardPath() {
2417
let path = "/usr/local/bin:/usr/bin:/bin:/usr/sbin:/sbin";
2518

@@ -461,6 +454,12 @@ function get_pkgx() {
461454
for (const path of Deno.env.get("PATH")!.split(":")) {
462455
const pkgx = join(path, "pkgx");
463456
if (existsSync(pkgx)) {
457+
const out = new Deno.Command(pkgx, { args: ["--version"] }).outputSync();
458+
const match = new TextDecoder().decode(out.stdout).match(/pkgx 2.(\d+)/);
459+
if (!match || parseInt(match[1]) < 4) {
460+
console.error("pkgm requires pkgx 2.4.0 or later");
461+
Deno.exit(1);
462+
}
464463
return pkgx;
465464
}
466465
}

0 commit comments

Comments
 (0)