diff --git a/devcheck.mjs b/devcheck.mjs index 9dd35cf..3bd1e42 100644 --- a/devcheck.mjs +++ b/devcheck.mjs @@ -61,12 +61,19 @@ if (existsSync(srcPath) && !isCI && !isInstalledPackage) { const scan = (tokens) => { for (let i = 0; i < tokens.length; i++) { if (tokens[i] === "--conditions" || tokens[i] === "-C") { - if (tokens[i + 1] !== undefined) conditions.push(tokens[i + 1]); + // Space form (`--conditions x` / `-C x`): consume the following token as this + // flag's value and SKIP it, so a value that itself looks like a flag (e.g. the + // literal `--conditions=x`) isn't re-interpreted on the next iteration. + if (tokens[i + 1] !== undefined) { + conditions.push(tokens[i + 1]); + i++; + } } else if (tokens[i].startsWith("--conditions=")) { conditions.push(tokens[i].slice("--conditions=".length)); - } else if (tokens[i].startsWith("-C=")) { - conditions.push(tokens[i].slice("-C=".length)); } + // Note: `-C=x` is intentionally not handled - Node rejects it ("bad option"), + // so it can never appear in execArgv/NODE_OPTIONS. Valid forms are + // `--conditions=x`, `--conditions x`, and `-C x`. } }; scan(process.execArgv); @@ -76,7 +83,7 @@ if (existsSync(srcPath) && !isCI && !isInstalledPackage) { if (!hasUUIDDev) { console.error("❌ Development environment not properly configured!"); console.error("📁 Source folder detected but the 'uuid-dev' condition is not set,"); - console.error(" so UUID is loading from dist/ instead of src/."); + console.error(" so imports resolve to dist/ by default (or fail if it isn't built) instead of src/."); console.error(""); console.error("🔧 To load from src/ for development, set the condition:"); console.error(" Windows (cmd):"); diff --git a/package-lock.json b/package-lock.json index e783720..b4766a0 100644 --- a/package-lock.json +++ b/package-lock.json @@ -1,12 +1,12 @@ { "name": "@cldmv/uuid", - "version": "1.1.5", + "version": "1.1.6", "lockfileVersion": 3, "requires": true, "packages": { "": { "name": "@cldmv/uuid", - "version": "1.1.5", + "version": "1.1.6", "license": "Apache-2.0", "devDependencies": { "@cldmv/fix-headers": "^1.2.2", diff --git a/package.json b/package.json index fdaf5b7..1ac1c4a 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "@cldmv/uuid", - "version": "1.1.5", + "version": "1.1.6", "description": "Extended RFC 4122 and RFC 9562 UUID implementation with custom variant structures, issuer-based identification, and timestamp variants", "main": "./index.cjs", "module": "./index.mjs", diff --git a/tests/DevCheck.test.vitest.mjs b/tests/DevCheck.test.vitest.mjs index de4dfea..0164f31 100644 --- a/tests/DevCheck.test.vitest.mjs +++ b/tests/DevCheck.test.vitest.mjs @@ -92,6 +92,14 @@ describe("devcheck", () => { expect(status).toBe(0); }); + test("stays silent via the -C short flag (Node's alias for --conditions)", () => { + // Node accepts `-C ` (space form) but rejects `-C=`, so only the + // space form is a real input to detect. + const { status, stderr } = runDevcheck({ src: true }, { nodeArgs: ["-C", "uuid-dev"] }); + expect(status).toBe(0); + expect(stderr).toBe(""); + }); + test("NODE_ENV=development alone does NOT silence it (only the condition selects src/)", () => { // Keying off NODE_ENV would be a false negative: dev env set but no condition means // the package is still resolving to dist/, which is exactly what should be flagged.