fix(cli): handle version flags before workspace discovery
This commit is contained in:
@@ -1,8 +1,12 @@
|
||||
import { afterEach, expect, test } from "bun:test";
|
||||
import { mkdtempSync, rmSync, writeFileSync } from "node:fs";
|
||||
import { tmpdir } from "node:os";
|
||||
import { join } from "node:path";
|
||||
import { compareVersions, notifyIfUpdateAvailable } from "../src/update-notifier.ts";
|
||||
import { join, resolve } from "node:path";
|
||||
import {
|
||||
compareVersions,
|
||||
currentCliVersion,
|
||||
notifyIfUpdateAvailable,
|
||||
} from "../src/update-notifier.ts";
|
||||
|
||||
const originalCache = process.env.WRNEXUS_UPDATE_CACHE;
|
||||
|
||||
@@ -35,3 +39,21 @@ test("cached update checks suggest the exact upgrade command", () => {
|
||||
rmSync(root, { recursive: true, force: true });
|
||||
}
|
||||
});
|
||||
|
||||
test("--version prints the package version outside a WrNexus workspace", () => {
|
||||
const root = mkdtempSync(join(tmpdir(), "wrnexus-version-"));
|
||||
try {
|
||||
const result = Bun.spawnSync({
|
||||
cmd: [process.execPath, resolve(import.meta.dir, "../src/index.ts"), "--version"],
|
||||
cwd: root,
|
||||
env: { ...process.env, WRNEXUS_NO_UPDATE_CHECK: "1" },
|
||||
stdout: "pipe",
|
||||
stderr: "pipe",
|
||||
});
|
||||
expect(result.exitCode).toBe(0);
|
||||
expect(result.stdout.toString().trim()).toBe(currentCliVersion());
|
||||
expect(result.stderr.toString()).toBe("");
|
||||
} finally {
|
||||
rmSync(root, { recursive: true, force: true });
|
||||
}
|
||||
});
|
||||
|
||||
Reference in New Issue
Block a user