Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
15 changes: 11 additions & 4 deletions devcheck.mjs
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand All @@ -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):");
Expand Down
4 changes: 2 additions & 2 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -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",
Expand Down
8 changes: 8 additions & 0 deletions tests/DevCheck.test.vitest.mjs
Original file line number Diff line number Diff line change
Expand Up @@ -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 <value>` (space form) but rejects `-C=<value>`, 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.
Expand Down
Loading