std-env 3.6.0 → 3.8.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/README.md CHANGED
@@ -73,7 +73,7 @@ List of well known providers can be found from [./src/providers.ts](./src/provid
73
73
  ```ts
74
74
  import { runtime, runtimeInfo } from "std-env";
75
75
 
76
- // "" | "node" | "deno" | "bun" | "workerd" | "lagon" ...
76
+ // "" | "node" | "deno" | "bun" | "workerd" ...
77
77
  console.log(runtime);
78
78
 
79
79
  // { name: "node" }
@@ -82,13 +82,17 @@ console.log(runtimeInfo);
82
82
 
83
83
  You can also use individual named exports for each runtime detection:
84
84
 
85
+ > [!NOTE]
86
+ > When running code in Bun and Deno with Node.js compatibility mode, `isNode` flag will be also `true`, indicating running in a Node.js compatible runtime.
87
+ >
88
+ > Use `runtime === "node"` if you need strict check for Node.js runtime.
89
+
90
+ - `isNode`
91
+ - `isBun`
92
+ - `isDeno`
85
93
  - `isNetlify`
86
94
  - `isEdgeLight`
87
95
  - `isWorkerd`
88
- - `isDeno`
89
- - `isLagon`
90
- - `isNode`
91
- - `isBun`
92
96
  - `isFastly`
93
97
 
94
98
  List of well known providers can be found from [./src/runtimes.ts](./src/runtimes.ts).
package/dist/index.cjs CHANGED
@@ -1 +1 @@
1
- "use strict";var b=Object.defineProperty;var a=Object.getOwnPropertySymbols;var P=Object.prototype.hasOwnProperty,x=Object.prototype.propertyIsEnumerable;var C=(i,e,n)=>e in i?b(i,e,{enumerable:!0,configurable:!0,writable:!0,value:n}):i[e]=n,R=(i,e)=>{for(var n in e||(e={}))P.call(e,n)&&C(i,n,e[n]);if(a)for(var n of a(e))x.call(e,n)&&C(i,n,e[n]);return i};var c,_,L,D,A,O,u,S,N,d;const r$2=Object.create(null),s=i=>{var e,n;return((e=globalThis.process)==null?void 0:e.env)||void 0||((n=globalThis.Deno)==null?void 0:n.env.toObject())||globalThis.__env__||(i?r$2:globalThis)},env=new Proxy(r$2,{get(i,e){var n;return(n=s()[e])!=null?n:r$2[e]},has(i,e){const n=s();return e in n||e in r$2},set(i,e,n){const E=s(!0);return E[e]=n,!0},deleteProperty(i,e){if(!e)return!1;const n=s(!0);return delete n[e],!0},ownKeys(){const i=s(!0);return Object.keys(i)}}),nodeENV=typeof process<"u"&&process.env&&process.env.NODE_ENV||"",r$1=[["APPVEYOR"],["AWS_AMPLIFY","AWS_APP_ID",{ci:!0}],["AZURE_PIPELINES","SYSTEM_TEAMFOUNDATIONCOLLECTIONURI"],["AZURE_STATIC","INPUT_AZURE_STATIC_WEB_APPS_API_TOKEN"],["APPCIRCLE","AC_APPCIRCLE"],["BAMBOO","bamboo_planKey"],["BITBUCKET","BITBUCKET_COMMIT"],["BITRISE","BITRISE_IO"],["BUDDY","BUDDY_WORKSPACE_ID"],["BUILDKITE"],["CIRCLE","CIRCLECI"],["CIRRUS","CIRRUS_CI"],["CLOUDFLARE_PAGES","CF_PAGES",{ci:!0}],["CODEBUILD","CODEBUILD_BUILD_ARN"],["CODEFRESH","CF_BUILD_ID"],["DRONE"],["DRONE","DRONE_BUILD_EVENT"],["DSARI"],["GITHUB_ACTIONS"],["GITLAB","GITLAB_CI"],["GITLAB","CI_MERGE_REQUEST_ID"],["GOCD","GO_PIPELINE_LABEL"],["LAYERCI"],["HUDSON","HUDSON_URL"],["JENKINS","JENKINS_URL"],["MAGNUM"],["NETLIFY"],["NETLIFY","NETLIFY_LOCAL",{ci:!1}],["NEVERCODE"],["RENDER"],["SAIL","SAILCI"],["SEMAPHORE"],["SCREWDRIVER"],["SHIPPABLE"],["SOLANO","TDDIUM"],["STRIDER"],["TEAMCITY","TEAMCITY_VERSION"],["TRAVIS"],["VERCEL","NOW_BUILDER"],["VERCEL","VERCEL",{ci:!1}],["VERCEL","VERCEL_ENV",{ci:!1}],["APPCENTER","APPCENTER_BUILD_ID"],["CODESANDBOX","CODESANDBOX_SSE",{ci:!1}],["STACKBLITZ"],["STORMKIT"],["CLEAVR"],["ZEABUR"],["CODESPHERE","CODESPHERE_APP_ID",{ci:!0}]];function I(){var i,e,n,E,T,p;if((i=globalThis.process)!=null&&i.env)for(const l of r$1){const g=l[1]||l[0];if((e=globalThis.process)!=null&&e.env[g])return R({name:l[0].toLowerCase()},l[2])}return((E=(n=globalThis.process)==null?void 0:n.env)==null?void 0:E.SHELL)==="/bin/jsh"&&((p=(T=globalThis.process)==null?void 0:T.versions)!=null&&p.webcontainer)?{name:"stackblitz",ci:!1}:{name:"",ci:!1}}const providerInfo=I(),provider=providerInfo.name;function toBoolean(i){return i?i!=="false":!1}const platform=((c=globalThis.process)==null?void 0:c.platform)||"",isCI=toBoolean(env.CI)||providerInfo.ci!==!1,hasTTY=toBoolean(((_=globalThis.process)==null?void 0:_.stdout)&&((L=globalThis.process)==null?void 0:L.stdout.isTTY)),hasWindow=typeof window<"u",isDebug=toBoolean(env.DEBUG),isTest=nodeENV==="test"||toBoolean(env.TEST),isProduction=nodeENV==="production",isDevelopment=nodeENV==="dev"||nodeENV==="development",isMinimal=toBoolean(env.MINIMAL)||isCI||isTest||!hasTTY,isWindows=/^win/i.test(platform),isLinux=/^linux/i.test(platform),isMacOS=/^darwin/i.test(platform),isColorSupported=!toBoolean(env.NO_COLOR)&&(toBoolean(env.FORCE_COLOR)||(hasTTY||isWindows)&&env.TERM!=="dumb"||isCI),nodeVersion=(((A=(D=globalThis.process)==null?void 0:D.versions)==null?void 0:A.node)||"").replace(/^v/,"")||null,nodeMajorVersion=Number(nodeVersion==null?void 0:nodeVersion.split(".")[0])||null,o$1=globalThis.process||Object.create(null),r={versions:{}},process$1=new Proxy(o$1,{get(i,e){if(e==="env")return env;if(e in i)return i[e];if(e in r)return r[e]}}),isNetlify=!!globalThis.Netlify,isEdgeLight=!!globalThis.EdgeRuntime,isWorkerd=((O=globalThis.navigator)==null?void 0:O.userAgent)==="Cloudflare-Workers",isDeno=!!globalThis.Deno,isLagon=!!globalThis.__lagon__,isNode=((S=(u=globalThis.process)==null?void 0:u.release)==null?void 0:S.name)==="node",isBun=!!globalThis.Bun||!!((d=(N=globalThis.process)==null?void 0:N.versions)!=null&&d.bun),isFastly=!!globalThis.fastly,o=[[isNetlify,"netlify"],[isEdgeLight,"edge-light"],[isWorkerd,"workerd"],[isDeno,"deno"],[isLagon,"lagon"],[isNode,"node"],[isBun,"bun"],[isFastly,"fastly"]];function t(){const i=o.find(e=>e[0]);if(i)return{name:i[1]}}const runtimeInfo=t(),runtime=(runtimeInfo==null?void 0:runtimeInfo.name)||"";exports.env=env,exports.hasTTY=hasTTY,exports.hasWindow=hasWindow,exports.isBun=isBun,exports.isCI=isCI,exports.isColorSupported=isColorSupported,exports.isDebug=isDebug,exports.isDeno=isDeno,exports.isDevelopment=isDevelopment,exports.isEdgeLight=isEdgeLight,exports.isFastly=isFastly,exports.isLagon=isLagon,exports.isLinux=isLinux,exports.isMacOS=isMacOS,exports.isMinimal=isMinimal,exports.isNetlify=isNetlify,exports.isNode=isNode,exports.isProduction=isProduction,exports.isTest=isTest,exports.isWindows=isWindows,exports.isWorkerd=isWorkerd,exports.nodeENV=nodeENV,exports.nodeMajorVersion=nodeMajorVersion,exports.nodeVersion=nodeVersion,exports.platform=platform,exports.process=process$1,exports.provider=provider,exports.providerInfo=providerInfo,exports.runtime=runtime,exports.runtimeInfo=runtimeInfo;
1
+ "use strict";var b=Object.defineProperty;var R=Object.getOwnPropertySymbols;var B=Object.prototype.hasOwnProperty,g=Object.prototype.propertyIsEnumerable;var C=(i,e,E)=>e in i?b(i,e,{enumerable:!0,configurable:!0,writable:!0,value:E}):i[e]=E,A=(i,e)=>{for(var E in e||(e={}))B.call(e,E)&&C(i,E,e[E]);if(R)for(var E of R(e))g.call(e,E)&&C(i,E,e[E]);return i};var _,a,D,L,c,O,S,N,u,P;const r$2=Object.create(null),s=i=>{var e,E;return((e=globalThis.process)==null?void 0:e.env)||void 0||((E=globalThis.Deno)==null?void 0:E.env.toObject())||globalThis.__env__||(i?r$2:globalThis)},env=new Proxy(r$2,{get(i,e){var E;return(E=s()[e])!=null?E:r$2[e]},has(i,e){const E=s();return e in E||e in r$2},set(i,e,E){const n=s(!0);return n[e]=E,!0},deleteProperty(i,e){if(!e)return!1;const E=s(!0);return delete E[e],!0},ownKeys(){const i=s(!0);return Object.keys(i)}}),nodeENV=typeof process<"u"&&process.env&&process.env.NODE_ENV||"",r$1=[["APPVEYOR"],["AWS_AMPLIFY","AWS_APP_ID",{ci:!0}],["AZURE_PIPELINES","SYSTEM_TEAMFOUNDATIONCOLLECTIONURI"],["AZURE_STATIC","INPUT_AZURE_STATIC_WEB_APPS_API_TOKEN"],["APPCIRCLE","AC_APPCIRCLE"],["BAMBOO","bamboo_planKey"],["BITBUCKET","BITBUCKET_COMMIT"],["BITRISE","BITRISE_IO"],["BUDDY","BUDDY_WORKSPACE_ID"],["BUILDKITE"],["CIRCLE","CIRCLECI"],["CIRRUS","CIRRUS_CI"],["CLOUDFLARE_PAGES","CF_PAGES",{ci:!0}],["CODEBUILD","CODEBUILD_BUILD_ARN"],["CODEFRESH","CF_BUILD_ID"],["DRONE"],["DRONE","DRONE_BUILD_EVENT"],["DSARI"],["GITHUB_ACTIONS"],["GITLAB","GITLAB_CI"],["GITLAB","CI_MERGE_REQUEST_ID"],["GOCD","GO_PIPELINE_LABEL"],["LAYERCI"],["HUDSON","HUDSON_URL"],["JENKINS","JENKINS_URL"],["MAGNUM"],["NETLIFY"],["NETLIFY","NETLIFY_LOCAL",{ci:!1}],["NEVERCODE"],["RENDER"],["SAIL","SAILCI"],["SEMAPHORE"],["SCREWDRIVER"],["SHIPPABLE"],["SOLANO","TDDIUM"],["STRIDER"],["TEAMCITY","TEAMCITY_VERSION"],["TRAVIS"],["VERCEL","NOW_BUILDER"],["VERCEL","VERCEL",{ci:!1}],["VERCEL","VERCEL_ENV",{ci:!1}],["APPCENTER","APPCENTER_BUILD_ID"],["CODESANDBOX","CODESANDBOX_SSE",{ci:!1}],["STACKBLITZ"],["STORMKIT"],["CLEAVR"],["ZEABUR"],["CODESPHERE","CODESPHERE_APP_ID",{ci:!0}],["RAILWAY","RAILWAY_PROJECT_ID"],["RAILWAY","RAILWAY_SERVICE_ID"],["DENO-DEPLOY","DENO_DEPLOYMENT_ID"],["FIREBASE_APP_HOSTING","FIREBASE_APP_HOSTING",{ci:!0}]];function I(){var i,e,E,n,T,p;if((i=globalThis.process)!=null&&i.env)for(const l of r$1){const d=l[1]||l[0];if((e=globalThis.process)!=null&&e.env[d])return A({name:l[0].toLowerCase()},l[2])}return((n=(E=globalThis.process)==null?void 0:E.env)==null?void 0:n.SHELL)==="/bin/jsh"&&((p=(T=globalThis.process)==null?void 0:T.versions)!=null&&p.webcontainer)?{name:"stackblitz",ci:!1}:{name:"",ci:!1}}const providerInfo=I(),provider=providerInfo.name;function toBoolean(i){return i?i!=="false":!1}const platform=((_=globalThis.process)==null?void 0:_.platform)||"",isCI=toBoolean(env.CI)||providerInfo.ci!==!1,hasTTY=toBoolean(((a=globalThis.process)==null?void 0:a.stdout)&&((D=globalThis.process)==null?void 0:D.stdout.isTTY)),hasWindow=typeof window<"u",isDebug=toBoolean(env.DEBUG),isTest=nodeENV==="test"||toBoolean(env.TEST),isProduction=nodeENV==="production",isDevelopment=nodeENV==="dev"||nodeENV==="development",isMinimal=toBoolean(env.MINIMAL)||isCI||isTest||!hasTTY,isWindows=/^win/i.test(platform),isLinux=/^linux/i.test(platform),isMacOS=/^darwin/i.test(platform),isColorSupported=!toBoolean(env.NO_COLOR)&&(toBoolean(env.FORCE_COLOR)||(hasTTY||isWindows)&&env.TERM!=="dumb"||isCI),nodeVersion=(((c=(L=globalThis.process)==null?void 0:L.versions)==null?void 0:c.node)||"").replace(/^v/,"")||null,nodeMajorVersion=Number(nodeVersion==null?void 0:nodeVersion.split(".")[0])||null,o$1=globalThis.process||Object.create(null),r={versions:{}},process$1=new Proxy(o$1,{get(i,e){if(e==="env")return env;if(e in i)return i[e];if(e in r)return r[e]}}),isNode=((S=(O=globalThis.process)==null?void 0:O.release)==null?void 0:S.name)==="node",isBun=!!globalThis.Bun||!!((u=(N=globalThis.process)==null?void 0:N.versions)!=null&&u.bun),isDeno=!!globalThis.Deno,isFastly=!!globalThis.fastly,isNetlify=!!globalThis.Netlify,isEdgeLight=!!globalThis.EdgeRuntime,isWorkerd=((P=globalThis.navigator)==null?void 0:P.userAgent)==="Cloudflare-Workers",t=[[isNetlify,"netlify"],[isEdgeLight,"edge-light"],[isWorkerd,"workerd"],[isFastly,"fastly"],[isDeno,"deno"],[isBun,"bun"],[isNode,"node"]];function o(){const i=t.find(e=>e[0]);if(i)return{name:i[1]}}const runtimeInfo=o(),runtime=(runtimeInfo==null?void 0:runtimeInfo.name)||"";exports.env=env,exports.hasTTY=hasTTY,exports.hasWindow=hasWindow,exports.isBun=isBun,exports.isCI=isCI,exports.isColorSupported=isColorSupported,exports.isDebug=isDebug,exports.isDeno=isDeno,exports.isDevelopment=isDevelopment,exports.isEdgeLight=isEdgeLight,exports.isFastly=isFastly,exports.isLinux=isLinux,exports.isMacOS=isMacOS,exports.isMinimal=isMinimal,exports.isNetlify=isNetlify,exports.isNode=isNode,exports.isProduction=isProduction,exports.isTest=isTest,exports.isWindows=isWindows,exports.isWorkerd=isWorkerd,exports.nodeENV=nodeENV,exports.nodeMajorVersion=nodeMajorVersion,exports.nodeVersion=nodeVersion,exports.platform=platform,exports.process=process$1,exports.provider=provider,exports.providerInfo=providerInfo,exports.runtime=runtime,exports.runtimeInfo=runtimeInfo;
package/dist/index.d.cts CHANGED
@@ -38,7 +38,7 @@ interface Process extends Partial<Omit<typeof globalThis.process, "versions">> {
38
38
  }
39
39
  declare const process: Process;
40
40
 
41
- type ProviderName = "" | "appveyor" | "aws_amplify" | "azure_pipelines" | "azure_static" | "appcircle" | "bamboo" | "bitbucket" | "bitrise" | "buddy" | "buildkite" | "circle" | "cirrus" | "cloudflare_pages" | "codebuild" | "codefresh" | "drone" | "drone" | "dsari" | "github_actions" | "gitlab" | "gocd" | "layerci" | "hudson" | "jenkins" | "magnum" | "netlify" | "nevercode" | "render" | "sail" | "semaphore" | "screwdriver" | "shippable" | "solano" | "strider" | "teamcity" | "travis" | "vercel" | "appcenter" | "codesandbox" | "stackblitz" | "stormkit" | "cleavr" | "zeabur" | "codesphere";
41
+ type ProviderName = "" | "appveyor" | "aws_amplify" | "azure_pipelines" | "azure_static" | "appcircle" | "bamboo" | "bitbucket" | "bitrise" | "buddy" | "buildkite" | "circle" | "cirrus" | "cloudflare_pages" | "codebuild" | "codefresh" | "drone" | "drone" | "dsari" | "github_actions" | "gitlab" | "gocd" | "layerci" | "hudson" | "jenkins" | "magnum" | "netlify" | "nevercode" | "render" | "sail" | "semaphore" | "screwdriver" | "shippable" | "solano" | "strider" | "teamcity" | "travis" | "vercel" | "appcenter" | "codesandbox" | "stackblitz" | "stormkit" | "cleavr" | "zeabur" | "codesphere" | "railway" | "deno-deploy" | "firebase_app_hosting";
42
42
  type ProviderInfo = {
43
43
  name: ProviderName;
44
44
  ci?: boolean;
@@ -48,19 +48,44 @@ type ProviderInfo = {
48
48
  declare const providerInfo: ProviderInfo;
49
49
  declare const provider: ProviderName;
50
50
 
51
- type RuntimeName = "workerd" | "deno" | "lagon" | "netlify" | "node" | "bun" | "edge-light" | "fastly" | "";
51
+ type RuntimeName = "workerd" | "deno" | "netlify" | "node" | "bun" | "edge-light" | "fastly" | "";
52
52
  type RuntimeInfo = {
53
53
  name: RuntimeName;
54
54
  };
55
- declare const isNetlify: boolean;
56
- declare const isEdgeLight: boolean;
57
- declare const isWorkerd: boolean;
58
- declare const isDeno: boolean;
59
- declare const isLagon: boolean;
55
+ /**
56
+ * Indicates if running in Node.js or a Node.js compatible runtime.
57
+ *
58
+ * **Note:** When running code in Bun and Deno with Node.js compatibility mode, `isNode` flag will be also `true`, indicating running in a Node.js compatible runtime.
59
+ *
60
+ * Use `runtime === "node"` if you need strict check for Node.js runtime.
61
+ */
60
62
  declare const isNode: boolean;
63
+ /**
64
+ * Indicates if running in Bun runtime.
65
+ */
61
66
  declare const isBun: boolean;
67
+ /**
68
+ * Indicates if running in Deno runtime.
69
+ */
70
+ declare const isDeno: boolean;
71
+ /**
72
+ * Indicates if running in Fastly runtime.
73
+ */
62
74
  declare const isFastly: boolean;
75
+ /**
76
+ * Indicates if running in Netlify runtime.
77
+ */
78
+ declare const isNetlify: boolean;
79
+ /**
80
+ *
81
+ * Indicates if running in EdgeLight (Vercel Edge) runtime.
82
+ */
83
+ declare const isEdgeLight: boolean;
84
+ /**
85
+ * Indicates if running in Cloudflare Workers runtime.
86
+ */
87
+ declare const isWorkerd: boolean;
63
88
  declare const runtimeInfo: RuntimeInfo | undefined;
64
89
  declare const runtime: RuntimeName;
65
90
 
66
- export { type EnvObject, type Process, type ProviderInfo, type ProviderName, type RuntimeInfo, type RuntimeName, env, hasTTY, hasWindow, isBun, isCI, isColorSupported, isDebug, isDeno, isDevelopment, isEdgeLight, isFastly, isLagon, isLinux, isMacOS, isMinimal, isNetlify, isNode, isProduction, isTest, isWindows, isWorkerd, nodeENV, nodeMajorVersion, nodeVersion, platform, process, provider, providerInfo, runtime, runtimeInfo };
91
+ export { type EnvObject, type Process, type ProviderInfo, type ProviderName, type RuntimeInfo, type RuntimeName, env, hasTTY, hasWindow, isBun, isCI, isColorSupported, isDebug, isDeno, isDevelopment, isEdgeLight, isFastly, isLinux, isMacOS, isMinimal, isNetlify, isNode, isProduction, isTest, isWindows, isWorkerd, nodeENV, nodeMajorVersion, nodeVersion, platform, process, provider, providerInfo, runtime, runtimeInfo };
package/dist/index.d.mts CHANGED
@@ -38,7 +38,7 @@ interface Process extends Partial<Omit<typeof globalThis.process, "versions">> {
38
38
  }
39
39
  declare const process: Process;
40
40
 
41
- type ProviderName = "" | "appveyor" | "aws_amplify" | "azure_pipelines" | "azure_static" | "appcircle" | "bamboo" | "bitbucket" | "bitrise" | "buddy" | "buildkite" | "circle" | "cirrus" | "cloudflare_pages" | "codebuild" | "codefresh" | "drone" | "drone" | "dsari" | "github_actions" | "gitlab" | "gocd" | "layerci" | "hudson" | "jenkins" | "magnum" | "netlify" | "nevercode" | "render" | "sail" | "semaphore" | "screwdriver" | "shippable" | "solano" | "strider" | "teamcity" | "travis" | "vercel" | "appcenter" | "codesandbox" | "stackblitz" | "stormkit" | "cleavr" | "zeabur" | "codesphere";
41
+ type ProviderName = "" | "appveyor" | "aws_amplify" | "azure_pipelines" | "azure_static" | "appcircle" | "bamboo" | "bitbucket" | "bitrise" | "buddy" | "buildkite" | "circle" | "cirrus" | "cloudflare_pages" | "codebuild" | "codefresh" | "drone" | "drone" | "dsari" | "github_actions" | "gitlab" | "gocd" | "layerci" | "hudson" | "jenkins" | "magnum" | "netlify" | "nevercode" | "render" | "sail" | "semaphore" | "screwdriver" | "shippable" | "solano" | "strider" | "teamcity" | "travis" | "vercel" | "appcenter" | "codesandbox" | "stackblitz" | "stormkit" | "cleavr" | "zeabur" | "codesphere" | "railway" | "deno-deploy" | "firebase_app_hosting";
42
42
  type ProviderInfo = {
43
43
  name: ProviderName;
44
44
  ci?: boolean;
@@ -48,19 +48,44 @@ type ProviderInfo = {
48
48
  declare const providerInfo: ProviderInfo;
49
49
  declare const provider: ProviderName;
50
50
 
51
- type RuntimeName = "workerd" | "deno" | "lagon" | "netlify" | "node" | "bun" | "edge-light" | "fastly" | "";
51
+ type RuntimeName = "workerd" | "deno" | "netlify" | "node" | "bun" | "edge-light" | "fastly" | "";
52
52
  type RuntimeInfo = {
53
53
  name: RuntimeName;
54
54
  };
55
- declare const isNetlify: boolean;
56
- declare const isEdgeLight: boolean;
57
- declare const isWorkerd: boolean;
58
- declare const isDeno: boolean;
59
- declare const isLagon: boolean;
55
+ /**
56
+ * Indicates if running in Node.js or a Node.js compatible runtime.
57
+ *
58
+ * **Note:** When running code in Bun and Deno with Node.js compatibility mode, `isNode` flag will be also `true`, indicating running in a Node.js compatible runtime.
59
+ *
60
+ * Use `runtime === "node"` if you need strict check for Node.js runtime.
61
+ */
60
62
  declare const isNode: boolean;
63
+ /**
64
+ * Indicates if running in Bun runtime.
65
+ */
61
66
  declare const isBun: boolean;
67
+ /**
68
+ * Indicates if running in Deno runtime.
69
+ */
70
+ declare const isDeno: boolean;
71
+ /**
72
+ * Indicates if running in Fastly runtime.
73
+ */
62
74
  declare const isFastly: boolean;
75
+ /**
76
+ * Indicates if running in Netlify runtime.
77
+ */
78
+ declare const isNetlify: boolean;
79
+ /**
80
+ *
81
+ * Indicates if running in EdgeLight (Vercel Edge) runtime.
82
+ */
83
+ declare const isEdgeLight: boolean;
84
+ /**
85
+ * Indicates if running in Cloudflare Workers runtime.
86
+ */
87
+ declare const isWorkerd: boolean;
63
88
  declare const runtimeInfo: RuntimeInfo | undefined;
64
89
  declare const runtime: RuntimeName;
65
90
 
66
- export { type EnvObject, type Process, type ProviderInfo, type ProviderName, type RuntimeInfo, type RuntimeName, env, hasTTY, hasWindow, isBun, isCI, isColorSupported, isDebug, isDeno, isDevelopment, isEdgeLight, isFastly, isLagon, isLinux, isMacOS, isMinimal, isNetlify, isNode, isProduction, isTest, isWindows, isWorkerd, nodeENV, nodeMajorVersion, nodeVersion, platform, process, provider, providerInfo, runtime, runtimeInfo };
91
+ export { type EnvObject, type Process, type ProviderInfo, type ProviderName, type RuntimeInfo, type RuntimeName, env, hasTTY, hasWindow, isBun, isCI, isColorSupported, isDebug, isDeno, isDevelopment, isEdgeLight, isFastly, isLinux, isMacOS, isMinimal, isNetlify, isNode, isProduction, isTest, isWindows, isWorkerd, nodeENV, nodeMajorVersion, nodeVersion, platform, process, provider, providerInfo, runtime, runtimeInfo };
package/dist/index.d.ts CHANGED
@@ -38,7 +38,7 @@ interface Process extends Partial<Omit<typeof globalThis.process, "versions">> {
38
38
  }
39
39
  declare const process: Process;
40
40
 
41
- type ProviderName = "" | "appveyor" | "aws_amplify" | "azure_pipelines" | "azure_static" | "appcircle" | "bamboo" | "bitbucket" | "bitrise" | "buddy" | "buildkite" | "circle" | "cirrus" | "cloudflare_pages" | "codebuild" | "codefresh" | "drone" | "drone" | "dsari" | "github_actions" | "gitlab" | "gocd" | "layerci" | "hudson" | "jenkins" | "magnum" | "netlify" | "nevercode" | "render" | "sail" | "semaphore" | "screwdriver" | "shippable" | "solano" | "strider" | "teamcity" | "travis" | "vercel" | "appcenter" | "codesandbox" | "stackblitz" | "stormkit" | "cleavr" | "zeabur" | "codesphere";
41
+ type ProviderName = "" | "appveyor" | "aws_amplify" | "azure_pipelines" | "azure_static" | "appcircle" | "bamboo" | "bitbucket" | "bitrise" | "buddy" | "buildkite" | "circle" | "cirrus" | "cloudflare_pages" | "codebuild" | "codefresh" | "drone" | "drone" | "dsari" | "github_actions" | "gitlab" | "gocd" | "layerci" | "hudson" | "jenkins" | "magnum" | "netlify" | "nevercode" | "render" | "sail" | "semaphore" | "screwdriver" | "shippable" | "solano" | "strider" | "teamcity" | "travis" | "vercel" | "appcenter" | "codesandbox" | "stackblitz" | "stormkit" | "cleavr" | "zeabur" | "codesphere" | "railway" | "deno-deploy" | "firebase_app_hosting";
42
42
  type ProviderInfo = {
43
43
  name: ProviderName;
44
44
  ci?: boolean;
@@ -48,19 +48,44 @@ type ProviderInfo = {
48
48
  declare const providerInfo: ProviderInfo;
49
49
  declare const provider: ProviderName;
50
50
 
51
- type RuntimeName = "workerd" | "deno" | "lagon" | "netlify" | "node" | "bun" | "edge-light" | "fastly" | "";
51
+ type RuntimeName = "workerd" | "deno" | "netlify" | "node" | "bun" | "edge-light" | "fastly" | "";
52
52
  type RuntimeInfo = {
53
53
  name: RuntimeName;
54
54
  };
55
- declare const isNetlify: boolean;
56
- declare const isEdgeLight: boolean;
57
- declare const isWorkerd: boolean;
58
- declare const isDeno: boolean;
59
- declare const isLagon: boolean;
55
+ /**
56
+ * Indicates if running in Node.js or a Node.js compatible runtime.
57
+ *
58
+ * **Note:** When running code in Bun and Deno with Node.js compatibility mode, `isNode` flag will be also `true`, indicating running in a Node.js compatible runtime.
59
+ *
60
+ * Use `runtime === "node"` if you need strict check for Node.js runtime.
61
+ */
60
62
  declare const isNode: boolean;
63
+ /**
64
+ * Indicates if running in Bun runtime.
65
+ */
61
66
  declare const isBun: boolean;
67
+ /**
68
+ * Indicates if running in Deno runtime.
69
+ */
70
+ declare const isDeno: boolean;
71
+ /**
72
+ * Indicates if running in Fastly runtime.
73
+ */
62
74
  declare const isFastly: boolean;
75
+ /**
76
+ * Indicates if running in Netlify runtime.
77
+ */
78
+ declare const isNetlify: boolean;
79
+ /**
80
+ *
81
+ * Indicates if running in EdgeLight (Vercel Edge) runtime.
82
+ */
83
+ declare const isEdgeLight: boolean;
84
+ /**
85
+ * Indicates if running in Cloudflare Workers runtime.
86
+ */
87
+ declare const isWorkerd: boolean;
63
88
  declare const runtimeInfo: RuntimeInfo | undefined;
64
89
  declare const runtime: RuntimeName;
65
90
 
66
- export { type EnvObject, type Process, type ProviderInfo, type ProviderName, type RuntimeInfo, type RuntimeName, env, hasTTY, hasWindow, isBun, isCI, isColorSupported, isDebug, isDeno, isDevelopment, isEdgeLight, isFastly, isLagon, isLinux, isMacOS, isMinimal, isNetlify, isNode, isProduction, isTest, isWindows, isWorkerd, nodeENV, nodeMajorVersion, nodeVersion, platform, process, provider, providerInfo, runtime, runtimeInfo };
91
+ export { type EnvObject, type Process, type ProviderInfo, type ProviderName, type RuntimeInfo, type RuntimeName, env, hasTTY, hasWindow, isBun, isCI, isColorSupported, isDebug, isDeno, isDevelopment, isEdgeLight, isFastly, isLinux, isMacOS, isMinimal, isNetlify, isNode, isProduction, isTest, isWindows, isWorkerd, nodeENV, nodeMajorVersion, nodeVersion, platform, process, provider, providerInfo, runtime, runtimeInfo };
package/dist/index.mjs CHANGED
@@ -1 +1 @@
1
- const r=Object.create(null),E=e=>globalThis.process?.env||import.meta.env||globalThis.Deno?.env.toObject()||globalThis.__env__||(e?r:globalThis),s=new Proxy(r,{get(e,o){return E()[o]??r[o]},has(e,o){const i=E();return o in i||o in r},set(e,o,i){const P=E(!0);return P[o]=i,!0},deleteProperty(e,o){if(!o)return!1;const i=E(!0);return delete i[o],!0},ownKeys(){const e=E(!0);return Object.keys(e)}}),t=typeof process<"u"&&process.env&&process.env.NODE_ENV||"",p=[["APPVEYOR"],["AWS_AMPLIFY","AWS_APP_ID",{ci:!0}],["AZURE_PIPELINES","SYSTEM_TEAMFOUNDATIONCOLLECTIONURI"],["AZURE_STATIC","INPUT_AZURE_STATIC_WEB_APPS_API_TOKEN"],["APPCIRCLE","AC_APPCIRCLE"],["BAMBOO","bamboo_planKey"],["BITBUCKET","BITBUCKET_COMMIT"],["BITRISE","BITRISE_IO"],["BUDDY","BUDDY_WORKSPACE_ID"],["BUILDKITE"],["CIRCLE","CIRCLECI"],["CIRRUS","CIRRUS_CI"],["CLOUDFLARE_PAGES","CF_PAGES",{ci:!0}],["CODEBUILD","CODEBUILD_BUILD_ARN"],["CODEFRESH","CF_BUILD_ID"],["DRONE"],["DRONE","DRONE_BUILD_EVENT"],["DSARI"],["GITHUB_ACTIONS"],["GITLAB","GITLAB_CI"],["GITLAB","CI_MERGE_REQUEST_ID"],["GOCD","GO_PIPELINE_LABEL"],["LAYERCI"],["HUDSON","HUDSON_URL"],["JENKINS","JENKINS_URL"],["MAGNUM"],["NETLIFY"],["NETLIFY","NETLIFY_LOCAL",{ci:!1}],["NEVERCODE"],["RENDER"],["SAIL","SAILCI"],["SEMAPHORE"],["SCREWDRIVER"],["SHIPPABLE"],["SOLANO","TDDIUM"],["STRIDER"],["TEAMCITY","TEAMCITY_VERSION"],["TRAVIS"],["VERCEL","NOW_BUILDER"],["VERCEL","VERCEL",{ci:!1}],["VERCEL","VERCEL_ENV",{ci:!1}],["APPCENTER","APPCENTER_BUILD_ID"],["CODESANDBOX","CODESANDBOX_SSE",{ci:!1}],["STACKBLITZ"],["STORMKIT"],["CLEAVR"],["ZEABUR"],["CODESPHERE","CODESPHERE_APP_ID",{ci:!0}]];function B(){if(globalThis.process?.env)for(const e of p){const o=e[1]||e[0];if(globalThis.process?.env[o])return{name:e[0].toLowerCase(),...e[2]}}return globalThis.process?.env?.SHELL==="/bin/jsh"&&globalThis.process?.versions?.webcontainer?{name:"stackblitz",ci:!1}:{name:"",ci:!1}}const I=B(),d=I.name;function n(e){return e?e!=="false":!1}const l=globalThis.process?.platform||"",T=n(s.CI)||I.ci!==!1,a=n(globalThis.process?.stdout&&globalThis.process?.stdout.isTTY),U=typeof window<"u",h=n(s.DEBUG),c=t==="test"||n(s.TEST),f=t==="production",v=t==="dev"||t==="development",m=n(s.MINIMAL)||T||c||!a,C=/^win/i.test(l),M=/^linux/i.test(l),V=/^darwin/i.test(l),y=!n(s.NO_COLOR)&&(n(s.FORCE_COLOR)||(a||C)&&s.TERM!=="dumb"||T),R=(globalThis.process?.versions?.node||"").replace(/^v/,"")||null,Y=Number(R?.split(".")[0])||null,w=globalThis.process||Object.create(null),_={versions:{}},F=new Proxy(w,{get(e,o){if(o==="env")return s;if(o in e)return e[o];if(o in _)return _[o]}}),L=!!globalThis.Netlify,A=!!globalThis.EdgeRuntime,D=globalThis.navigator?.userAgent==="Cloudflare-Workers",O=!!globalThis.Deno,S=!!globalThis.__lagon__,N=globalThis.process?.release?.name==="node",u=!!globalThis.Bun||!!globalThis.process?.versions?.bun,b=!!globalThis.fastly,G=[[L,"netlify"],[A,"edge-light"],[D,"workerd"],[O,"deno"],[S,"lagon"],[N,"node"],[u,"bun"],[b,"fastly"]];function K(){const e=G.find(o=>o[0]);if(e)return{name:e[1]}}const g=K(),W=g?.name||"";export{s as env,a as hasTTY,U as hasWindow,u as isBun,T as isCI,y as isColorSupported,h as isDebug,O as isDeno,v as isDevelopment,A as isEdgeLight,b as isFastly,S as isLagon,M as isLinux,V as isMacOS,m as isMinimal,L as isNetlify,N as isNode,f as isProduction,c as isTest,C as isWindows,D as isWorkerd,t as nodeENV,Y as nodeMajorVersion,R as nodeVersion,l as platform,F as process,d as provider,I as providerInfo,W as runtime,g as runtimeInfo};
1
+ const r=Object.create(null),i=e=>globalThis.process?.env||import.meta.env||globalThis.Deno?.env.toObject()||globalThis.__env__||(e?r:globalThis),s=new Proxy(r,{get(e,o){return i()[o]??r[o]},has(e,o){const E=i();return o in E||o in r},set(e,o,E){const b=i(!0);return b[o]=E,!0},deleteProperty(e,o){if(!o)return!1;const E=i(!0);return delete E[o],!0},ownKeys(){const e=i(!0);return Object.keys(e)}}),t=typeof process<"u"&&process.env&&process.env.NODE_ENV||"",B=[["APPVEYOR"],["AWS_AMPLIFY","AWS_APP_ID",{ci:!0}],["AZURE_PIPELINES","SYSTEM_TEAMFOUNDATIONCOLLECTIONURI"],["AZURE_STATIC","INPUT_AZURE_STATIC_WEB_APPS_API_TOKEN"],["APPCIRCLE","AC_APPCIRCLE"],["BAMBOO","bamboo_planKey"],["BITBUCKET","BITBUCKET_COMMIT"],["BITRISE","BITRISE_IO"],["BUDDY","BUDDY_WORKSPACE_ID"],["BUILDKITE"],["CIRCLE","CIRCLECI"],["CIRRUS","CIRRUS_CI"],["CLOUDFLARE_PAGES","CF_PAGES",{ci:!0}],["CODEBUILD","CODEBUILD_BUILD_ARN"],["CODEFRESH","CF_BUILD_ID"],["DRONE"],["DRONE","DRONE_BUILD_EVENT"],["DSARI"],["GITHUB_ACTIONS"],["GITLAB","GITLAB_CI"],["GITLAB","CI_MERGE_REQUEST_ID"],["GOCD","GO_PIPELINE_LABEL"],["LAYERCI"],["HUDSON","HUDSON_URL"],["JENKINS","JENKINS_URL"],["MAGNUM"],["NETLIFY"],["NETLIFY","NETLIFY_LOCAL",{ci:!1}],["NEVERCODE"],["RENDER"],["SAIL","SAILCI"],["SEMAPHORE"],["SCREWDRIVER"],["SHIPPABLE"],["SOLANO","TDDIUM"],["STRIDER"],["TEAMCITY","TEAMCITY_VERSION"],["TRAVIS"],["VERCEL","NOW_BUILDER"],["VERCEL","VERCEL",{ci:!1}],["VERCEL","VERCEL_ENV",{ci:!1}],["APPCENTER","APPCENTER_BUILD_ID"],["CODESANDBOX","CODESANDBOX_SSE",{ci:!1}],["STACKBLITZ"],["STORMKIT"],["CLEAVR"],["ZEABUR"],["CODESPHERE","CODESPHERE_APP_ID",{ci:!0}],["RAILWAY","RAILWAY_PROJECT_ID"],["RAILWAY","RAILWAY_SERVICE_ID"],["DENO-DEPLOY","DENO_DEPLOYMENT_ID"],["FIREBASE_APP_HOSTING","FIREBASE_APP_HOSTING",{ci:!0}]];function p(){if(globalThis.process?.env)for(const e of B){const o=e[1]||e[0];if(globalThis.process?.env[o])return{name:e[0].toLowerCase(),...e[2]}}return globalThis.process?.env?.SHELL==="/bin/jsh"&&globalThis.process?.versions?.webcontainer?{name:"stackblitz",ci:!1}:{name:"",ci:!1}}const l=p(),d=l.name;function n(e){return e?e!=="false":!1}const I=globalThis.process?.platform||"",T=n(s.CI)||l.ci!==!1,R=n(globalThis.process?.stdout&&globalThis.process?.stdout.isTTY),g=typeof window<"u",U=n(s.DEBUG),A=t==="test"||n(s.TEST),h=t==="production",f=t==="dev"||t==="development",v=n(s.MINIMAL)||T||A||!R,_=/^win/i.test(I),M=/^linux/i.test(I),m=/^darwin/i.test(I),Y=!n(s.NO_COLOR)&&(n(s.FORCE_COLOR)||(R||_)&&s.TERM!=="dumb"||T),C=(globalThis.process?.versions?.node||"").replace(/^v/,"")||null,V=Number(C?.split(".")[0])||null,y=globalThis.process||Object.create(null),c={versions:{}},W=new Proxy(y,{get(e,o){if(o==="env")return s;if(o in e)return e[o];if(o in c)return c[o]}}),L=globalThis.process?.release?.name==="node",a=!!globalThis.Bun||!!globalThis.process?.versions?.bun,D=!!globalThis.Deno,O=!!globalThis.fastly,S=!!globalThis.Netlify,N=!!globalThis.EdgeRuntime,P=globalThis.navigator?.userAgent==="Cloudflare-Workers",F=[[S,"netlify"],[N,"edge-light"],[P,"workerd"],[O,"fastly"],[D,"deno"],[a,"bun"],[L,"node"]];function G(){const e=F.find(o=>o[0]);if(e)return{name:e[1]}}const u=G(),w=u?.name||"";export{s as env,R as hasTTY,g as hasWindow,a as isBun,T as isCI,Y as isColorSupported,U as isDebug,D as isDeno,f as isDevelopment,N as isEdgeLight,O as isFastly,M as isLinux,m as isMacOS,v as isMinimal,S as isNetlify,L as isNode,h as isProduction,A as isTest,_ as isWindows,P as isWorkerd,t as nodeENV,V as nodeMajorVersion,C as nodeVersion,I as platform,W as process,d as provider,l as providerInfo,w as runtime,u as runtimeInfo};
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "std-env",
3
- "version": "3.6.0",
3
+ "version": "3.8.0",
4
4
  "description": "Runtime agnostic JS utils",
5
5
  "repository": "unjs/std-env",
6
6
  "license": "MIT",
@@ -18,8 +18,8 @@
18
18
  "scripts": {
19
19
  "build": "unbuild",
20
20
  "dev": "vitest",
21
- "lint": "eslint --ext .ts . && prettier -c src test",
22
- "lint:fix": "eslint --fix --ext .ts . && prettier -w src test",
21
+ "lint": "eslint . && prettier -c src test",
22
+ "lint:fix": "eslint --fix . && prettier -w src test",
23
23
  "prepack": "unbuild",
24
24
  "play:bun": "bun playground/bun.ts",
25
25
  "play:deno": "pnpm build && deno run -A playground/deno.ts",
@@ -29,18 +29,18 @@
29
29
  "typecheck": "tsc --noEmit"
30
30
  },
31
31
  "devDependencies": {
32
- "@types/node": "^20.10.1",
33
- "@vitest/coverage-v8": "^0.34.6",
34
- "changelogen": "^0.5.5",
35
- "esbuild": "^0.19.8",
36
- "eslint": "^8.54.0",
37
- "eslint-config-unjs": "^0.2.1",
38
- "jiti": "^1.21.0",
39
- "prettier": "^3.1.0",
40
- "rollup": "^4.6.1",
41
- "typescript": "^5.3.2",
32
+ "@types/node": "^22.9.0",
33
+ "@vitest/coverage-v8": "^2.1.4",
34
+ "changelogen": "^0.5.7",
35
+ "esbuild": "^0.24.0",
36
+ "eslint": "^9.14.0",
37
+ "eslint-config-unjs": "^0.4.1",
38
+ "jiti": "^2.4.0",
39
+ "prettier": "^3.3.3",
40
+ "rollup": "^4.24.4",
41
+ "typescript": "^5.6.3",
42
42
  "unbuild": "^2.0.0",
43
- "vitest": "^0.34.6"
43
+ "vitest": "^2.1.4"
44
44
  },
45
- "packageManager": "pnpm@8.11.0"
46
- }
45
+ "packageManager": "pnpm@9.12.3"
46
+ }