fix(cli): handle version flags before workspace discovery
This commit is contained in:
@@ -292,7 +292,7 @@
|
|||||||
},
|
},
|
||||||
"packages/cli": {
|
"packages/cli": {
|
||||||
"name": "@wrnexus/cli",
|
"name": "@wrnexus/cli",
|
||||||
"version": "0.8.62",
|
"version": "0.8.63",
|
||||||
"bin": {
|
"bin": {
|
||||||
"wrnexus": "src/index.ts",
|
"wrnexus": "src/index.ts",
|
||||||
},
|
},
|
||||||
|
|||||||
@@ -1,6 +1,6 @@
|
|||||||
{
|
{
|
||||||
"name": "@wrnexus/cli",
|
"name": "@wrnexus/cli",
|
||||||
"version": "0.8.62",
|
"version": "0.8.63",
|
||||||
"type": "module",
|
"type": "module",
|
||||||
"main": "src/index.ts",
|
"main": "src/index.ts",
|
||||||
"exports": {
|
"exports": {
|
||||||
|
|||||||
@@ -113,6 +113,11 @@ Update options: --dry-run previews changes; --no-verify skips post-update check/
|
|||||||
async function main(): Promise<void> {
|
async function main(): Promise<void> {
|
||||||
const [command, ...rest] = process.argv.slice(2);
|
const [command, ...rest] = process.argv.slice(2);
|
||||||
|
|
||||||
|
if (command === "--version" || command === "-v" || command === "version") {
|
||||||
|
console.log(currentCliVersion());
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
notifyIfUpdateAvailable(currentCliVersion(), command);
|
notifyIfUpdateAvailable(currentCliVersion(), command);
|
||||||
|
|
||||||
switch (command) {
|
switch (command) {
|
||||||
|
|||||||
@@ -1,8 +1,12 @@
|
|||||||
import { afterEach, expect, test } from "bun:test";
|
import { afterEach, expect, test } from "bun:test";
|
||||||
import { mkdtempSync, rmSync, writeFileSync } from "node:fs";
|
import { mkdtempSync, rmSync, writeFileSync } from "node:fs";
|
||||||
import { tmpdir } from "node:os";
|
import { tmpdir } from "node:os";
|
||||||
import { join } from "node:path";
|
import { join, resolve } from "node:path";
|
||||||
import { compareVersions, notifyIfUpdateAvailable } from "../src/update-notifier.ts";
|
import {
|
||||||
|
compareVersions,
|
||||||
|
currentCliVersion,
|
||||||
|
notifyIfUpdateAvailable,
|
||||||
|
} from "../src/update-notifier.ts";
|
||||||
|
|
||||||
const originalCache = process.env.WRNEXUS_UPDATE_CACHE;
|
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 });
|
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