diff --git a/AGENTS.md b/AGENTS.md index 5eda851..1693650 100644 --- a/AGENTS.md +++ b/AGENTS.md @@ -88,6 +88,7 @@ All detection modules follow the same pattern: - Priority order: netlify → edge-light → workerd → fastly → deno → bun → node - Uses global objects (e.g., `globalThis.Bun`, `globalThis.Deno`, `navigator.userAgent`) - `isNode` is true for Node-compatible runtimes (Bun, Deno with compat); use `runtime === "node"` for strict check +- `isNub` (`!!process.versions.nub`) detects [Nub](https://github.com/nubjs/nub), a Node.js augmentation layer — additive, so `isNode` stays true and `runtime` stays `"node"`; it is deliberately NOT in `runtimeChecks` or `RuntimeName` ### Flags (`src/flags.ts`) diff --git a/README.md b/README.md index f6cb308..5b3492b 100644 --- a/README.md +++ b/README.md @@ -17,10 +17,12 @@ console.log(runtime); // "" | "node" | "deno" | "bun" | "workerd" ... console.log(runtimeInfo); // { name: "node" } ``` -Individual named exports: `isNode`, `isBun`, `isDeno`, `isNetlify`, `isEdgeLight`, `isWorkerd`, `isFastly` +Individual named exports: `isNode`, `isBun`, `isDeno`, `isNetlify`, `isEdgeLight`, `isWorkerd`, `isFastly`, `isNub` > [!NOTE] > `isNode` is also `true` in Bun/Deno with Node.js compatibility mode. Use `runtime === "node"` for strict checks. +> +> `isNub` detects [Nub](https://github.com/nubjs/nub), which augments Node.js rather than replacing it. It is additive: `isNode` is also `true` and `runtime` stays `"node"`. See [./src/runtimes.ts](./src/runtimes.ts) for the full list. diff --git a/src/index.ts b/src/index.ts index 4bc2e48..7f2a5ba 100644 --- a/src/index.ts +++ b/src/index.ts @@ -41,6 +41,7 @@ export { isBun, isDeno, isNode, + isNub, runtime, runtimeInfo, isEdgeLight, diff --git a/src/runtimes.ts b/src/runtimes.ts index f57148d..14b512f 100644 --- a/src/runtimes.ts +++ b/src/runtimes.ts @@ -31,6 +31,15 @@ export type RuntimeInfo = { */ export const isNode: boolean = !!process?.versions?.node; +/** + * Indicates if running under [Nub](https://github.com/nubjs/nub). + * + * **Note:** Nub augments Node.js rather than replacing it, so `isNode` is also `true` and + * `runtime` stays `"node"`. This flag is additive — it detects the Nub augmentation layer + * on top of Node. + */ +export const isNub: boolean = !!process?.versions?.nub; + /** * Indicates if running in Bun runtime. */ diff --git a/test/index.test.ts b/test/index.test.ts index ff7e411..49b5277 100644 --- a/test/index.test.ts +++ b/test/index.test.ts @@ -14,6 +14,7 @@ describe("std-env", () => { isProduction: false, isDevelopment: false, isMinimal: true, + isNub: false, isWindows: expect.any(Boolean), isLinux: expect.any(Boolean), isMacOS: expect.any(Boolean),