{"id":13457643,"url":"https://github.com/unjs/std-env","last_synced_at":"2025-06-10T22:41:49.666Z","repository":{"id":39716406,"uuid":"127458049","full_name":"unjs/std-env","owner":"unjs","description":"Runtime Agnostic JS utils","archived":false,"fork":false,"pushed_at":"2025-03-03T12:43:02.000Z","size":886,"stargazers_count":510,"open_issues_count":17,"forks_count":26,"subscribers_count":4,"default_branch":"main","last_synced_at":"2025-03-20T21:21:37.010Z","etag":null,"topics":["ci","cli","console","environment","node","std","tty"],"latest_commit_sha":null,"homepage":"","language":"TypeScript","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/unjs.png","metadata":{"files":{"readme":"README.md","changelog":"CHANGELOG.md","contributing":null,"funding":null,"license":null,"code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null}},"created_at":"2018-03-30T18:02:57.000Z","updated_at":"2025-03-20T20:32:15.000Z","dependencies_parsed_at":"2024-01-17T03:55:10.076Z","dependency_job_id":"1bd0451d-e74f-4cc1-8bcd-137e2eb3b286","html_url":"https://github.com/unjs/std-env","commit_stats":{"total_commits":208,"total_committers":23,"mean_commits":9.043478260869565,"dds":0.6298076923076923,"last_synced_commit":"16c5d9d39d9dea34f6b77e7ffc9059bbb638e802"},"previous_names":[],"tags_count":33,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/unjs%2Fstd-env","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/unjs%2Fstd-env/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/unjs%2Fstd-env/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/unjs%2Fstd-env/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/unjs","download_url":"https://codeload.github.com/unjs/std-env/tar.gz/refs/heads/main","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":244738930,"owners_count":20501945,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["ci","cli","console","environment","node","std","tty"],"created_at":"2024-07-31T09:00:32.765Z","updated_at":"2025-03-24T14:32:08.422Z","avatar_url":"https://github.com/unjs.png","language":"TypeScript","readme":"# std-env\n\n[![npm](https://img.shields.io/npm/dm/std-env.svg?style=flat-square)](http://npmjs.com/package/std-env)\n[![npm](https://img.shields.io/npm/v/std-env.svg?style=flat-square)](http://npmjs.com/package/std-env)\n[![bundlephobia](https://img.shields.io/bundlephobia/min/std-env/latest.svg?style=flat-square)](https://bundlephobia.com/result?p=std-env)\n\n\u003e Runtime agnostic JS utils\n\n## Installation\n\n```sh\n# Using npm\nnpm i std-env\n\n# Using pnpm\npnpm i std-env\n\n# Using yarn\nyarn add std-env\n```\n\n## Usage\n\n```js\n// ESM\nimport { env, isDevelopment, isProduction } from \"std-env\";\n\n// CommonJS\nconst { env, isDevelopment, isProduction } = require(\"std-env\");\n```\n\n## Flags\n\n- `hasTTY`\n- `hasWindow`\n- `isDebug`\n- `isDevelopment`\n- `isLinux`\n- `isMacOS`\n- `isMinimal`\n- `isProduction`\n- `isTest`\n- `isWindows`\n- `platform`\n- `isColorSupported`\n- `nodeVersion`\n- `nodeMajorVersion`\n\nYou can read more about how each flag works from [./src/flags.ts](./src/flags.ts).\n\n## Provider Detection\n\n`std-env` can automatically detect the current runtime provider based on environment variables.\n\nYou can use `isCI` and `platform` exports to detect it:\n\n```ts\nimport { isCI, provider, providerInfo } from \"std-env\";\n\nconsole.log({\n  isCI, // true\n  provider, // \"github_actions\"\n  providerInfo, // { name: \"github_actions\", isCI: true }\n});\n```\n\nList of well known providers can be found from [./src/providers.ts](./src/providers.ts).\n\n## Runtime Detection\n\n`std-env` can automatically detect the current JavaScript runtime based on global variables, following the [WinterCG Runtime Keys proposal](https://runtime-keys.proposal.wintercg.org/):\n\n```ts\nimport { runtime, runtimeInfo } from \"std-env\";\n\n// \"\" | \"node\" | \"deno\" | \"bun\" | \"workerd\" ...\nconsole.log(runtime);\n\n// { name: \"node\" }\nconsole.log(runtimeInfo);\n```\n\nYou can also use individual named exports for each runtime detection:\n\n\u003e [!NOTE]\n\u003e 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.\n\u003e\n\u003e Use `runtime === \"node\"` if you need strict check for Node.js runtime.\n\n- `isNode`\n- `isBun`\n- `isDeno`\n- `isNetlify`\n- `isEdgeLight`\n- `isWorkerd`\n- `isFastly`\n\nList of well known providers can be found from [./src/runtimes.ts](./src/runtimes.ts).\n\n## Platform-Agnostic `env`\n\n`std-env` provides a lightweight proxy to access environment variables in a platform agnostic way.\n\n```ts\nimport { env } from \"std-env\";\n```\n\n## Platform-Agnostic `process`\n\n`std-env` provides a lightweight proxy to access [`process`](https://nodejs.org/api/process.html) object in a platform agnostic way.\n\n```ts\nimport { process } from \"std-env\";\n```\n\n## License\n\nMIT\n","funding_links":[],"categories":["TypeScript","cli"],"sub_categories":[],"project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Funjs%2Fstd-env","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Funjs%2Fstd-env","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Funjs%2Fstd-env/lists"}