From e7e05777f84e7272d6e1eba32f8d0097621fed92 Mon Sep 17 00:00:00 2001 From: Colin McDonnell <3084745+colinhacks@users.noreply.github.com> Date: Tue, 7 Jul 2026 16:02:28 -0700 Subject: [PATCH 1/2] feat: add isNub runtime detection --- AGENTS.md | 1 + README.md | 5 ++++- src/index.ts | 1 + src/runtimes.ts | 9 +++++++++ test/index.test.ts | 1 + 5 files changed, 16 insertions(+), 1 deletion(-) 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..06c1552 100644 --- a/README.md +++ b/README.md @@ -17,11 +17,14 @@ 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. +> [!NOTE] +> `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. ## Provider Detection 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), From ad3f3c74c0aa28a2da7f0b447a56243e4f0f6b23 Mon Sep 17 00:00:00 2001 From: Colin McDonnell <3084745+colinhacks@users.noreply.github.com> Date: Tue, 7 Jul 2026 16:18:57 -0700 Subject: [PATCH 2/2] docs: merge isNode/isNub notes into one blockquote (markdownlint MD028) --- README.md | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/README.md b/README.md index 06c1552..5b3492b 100644 --- a/README.md +++ b/README.md @@ -21,8 +21,7 @@ Individual named exports: `isNode`, `isBun`, `isDeno`, `isNetlify`, `isEdgeLight > [!NOTE] > `isNode` is also `true` in Bun/Deno with Node.js compatibility mode. Use `runtime === "node"` for strict checks. - -> [!NOTE] +> > `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.