Skip to content
Closed
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
13 changes: 10 additions & 3 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 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.

5 changes: 3 additions & 2 deletions 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 All @@ -16,7 +16,8 @@
"import": "./src/uuid.mjs"
},
"import": "./dist/uuid.mjs"
}
},
"./package.json": "./package.json"
},
"type": "module",
"engines": {
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
40 changes: 40 additions & 0 deletions tests/package-exports.test.vitest.mjs
Original file line number Diff line number Diff line change
@@ -0,0 +1,40 @@
/**
* @Project: @cldmv/uuid
* @Filename: /tests/package-exports.test.vitest.mjs
* @Date: 2026-08-09T00:00:00-08:00 (1786233600)
* @Author: Nate Corcoran <CLDMV>
* @Email: <Shinrai@users.noreply.github.com>
* -----
* @Last modified by: Nate Corcoran <CLDMV> (Shinrai@users.noreply.github.com)
* @Last modified time: 2026-08-09T00:00:00-08:00 (1786233600)
* -----
* @Copyright: Copyright (c) 2013-2026 Catalyzed Motivation Inc. All rights reserved.
*/

import { test, expect, describe } from "vitest";
import { readFileSync } from "node:fs";
import { spawnSync } from "node:child_process";
import path from "node:path";
import { fileURLToPath } from "node:url";

const repoRoot = path.resolve(path.dirname(fileURLToPath(import.meta.url)), "..");

describe("package exports", () => {
test("the exports map exposes ./package.json", () => {
// Tooling resolves `<pkg>/package.json` to locate a package's directory on disk;
// omitting it from `exports` makes that throw ERR_PACKAGE_PATH_NOT_EXPORTED. (#6)
const pkg = JSON.parse(readFileSync(path.join(repoRoot, "package.json"), "utf8"));
expect(pkg.exports["./package.json"]).toBe("./package.json");
});

test("Node can resolve @cldmv/uuid/package.json through the exports map", () => {
// Real Node resolution (self-referencing the package by name from the repo root),
// not Vitest's resolver β€” before the fix this exits non-zero with
// ERR_PACKAGE_PATH_NOT_EXPORTED.
const res = spawnSync(process.execPath, ["--input-type=module", "-e", "import.meta.resolve('@cldmv/uuid/package.json');"], {
cwd: repoRoot,
encoding: "utf8"
});
expect(res.status).toBe(0);
});
});
Loading