{"id":21686176,"url":"https://github.com/val-istar-guo/detect-env","last_synced_at":"2025-10-13T09:36:57.814Z","repository":{"id":134480163,"uuid":"87697696","full_name":"Val-istar-Guo/detect-env","owner":"Val-istar-Guo","description":"Used to return value accroding to  process.env.NODE_ENV","archived":false,"fork":false,"pushed_at":"2017-11-21T15:34:42.000Z","size":63,"stargazers_count":1,"open_issues_count":0,"forks_count":0,"subscribers_count":1,"default_branch":"master","last_synced_at":"2025-06-14T10:40:31.814Z","etag":null,"topics":["detect","detect-env","env","koa","koa2","node"],"latest_commit_sha":null,"homepage":"","language":"JavaScript","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/Val-istar-Guo.png","metadata":{"files":{"readme":"README.md","changelog":"HISTORY.md","contributing":null,"funding":null,"license":"LICENSE","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":"2017-04-09T09:36:46.000Z","updated_at":"2017-09-04T12:29:23.000Z","dependencies_parsed_at":"2023-05-04T21:02:32.474Z","dependency_job_id":null,"html_url":"https://github.com/Val-istar-Guo/detect-env","commit_stats":null,"previous_names":[],"tags_count":10,"template":false,"template_full_name":null,"purl":"pkg:github/Val-istar-Guo/detect-env","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Val-istar-Guo%2Fdetect-env","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Val-istar-Guo%2Fdetect-env/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Val-istar-Guo%2Fdetect-env/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Val-istar-Guo%2Fdetect-env/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/Val-istar-Guo","download_url":"https://codeload.github.com/Val-istar-Guo/detect-env/tar.gz/refs/heads/master","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Val-istar-Guo%2Fdetect-env/sbom","scorecard":{"id":146990,"data":{"date":"2025-08-11","repo":{"name":"github.com/Val-istar-Guo/detect-env","commit":"8d2e3af4bb49a82e001af12f73d6fe54b5c98121"},"scorecard":{"version":"v5.2.1-40-gf6ed084d","commit":"f6ed084d17c9236477efd66e5b258b9d4cc7b389"},"score":3,"checks":[{"name":"Binary-Artifacts","score":10,"reason":"no binaries found in the repo","details":null,"documentation":{"short":"Determines if the project has generated executable (binary) artifacts in the source repository.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#binary-artifacts"}},{"name":"Packaging","score":-1,"reason":"packaging workflow not detected","details":["Warn: no GitHub/GitLab publishing workflow detected."],"documentation":{"short":"Determines if the project is published as a package that others can easily download, install, easily update, and uninstall.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#packaging"}},{"name":"Dangerous-Workflow","score":-1,"reason":"no workflows found","details":null,"documentation":{"short":"Determines if the project's GitHub Action workflows avoid dangerous patterns.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#dangerous-workflow"}},{"name":"Code-Review","score":0,"reason":"Found 0/30 approved changesets -- score normalized to 0","details":null,"documentation":{"short":"Determines if the project requires human code review before pull requests (aka merge requests) are merged.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#code-review"}},{"name":"Pinned-Dependencies","score":-1,"reason":"no dependencies found","details":null,"documentation":{"short":"Determines if the project has declared and pinned the dependencies of its build process.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#pinned-dependencies"}},{"name":"SAST","score":0,"reason":"no SAST tool detected","details":["Warn: no pull requests merged into dev branch"],"documentation":{"short":"Determines if the project uses static code analysis.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#sast"}},{"name":"Maintained","score":0,"reason":"project is archived","details":["Warn: Repository is archived."],"documentation":{"short":"Determines if the project is \"actively maintained\".","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#maintained"}},{"name":"Token-Permissions","score":-1,"reason":"No tokens found","details":null,"documentation":{"short":"Determines if the project's workflows follow the principle of least privilege.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#token-permissions"}},{"name":"CII-Best-Practices","score":0,"reason":"no effort to earn an OpenSSF best practices badge detected","details":null,"documentation":{"short":"Determines if the project has an OpenSSF (formerly CII) Best Practices Badge.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#cii-best-practices"}},{"name":"Security-Policy","score":0,"reason":"security policy file not detected","details":["Warn: no security policy file detected","Warn: no security file to analyze","Warn: no security file to analyze","Warn: no security file to analyze"],"documentation":{"short":"Determines if the project has published a security policy.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#security-policy"}},{"name":"Fuzzing","score":0,"reason":"project is not fuzzed","details":["Warn: no fuzzer integrations found"],"documentation":{"short":"Determines if the project uses fuzzing.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#fuzzing"}},{"name":"Vulnerabilities","score":10,"reason":"0 existing vulnerabilities detected","details":null,"documentation":{"short":"Determines if the project has open, known unfixed vulnerabilities.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#vulnerabilities"}},{"name":"License","score":10,"reason":"license file detected","details":["Info: project has a license file: LICENSE:0","Info: FSF or OSI recognized license: MIT License: LICENSE:0"],"documentation":{"short":"Determines if the project has defined a license.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#license"}},{"name":"Signed-Releases","score":-1,"reason":"no releases found","details":null,"documentation":{"short":"Determines if the project cryptographically signs release artifacts.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#signed-releases"}},{"name":"Branch-Protection","score":0,"reason":"branch protection not enabled on development/release branches","details":["Warn: branch protection not enabled for branch 'master'"],"documentation":{"short":"Determines if the default and release branches are protected with GitHub's branch protection settings.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#branch-protection"}}]},"last_synced_at":"2025-08-16T09:35:10.654Z","repository_id":134480163,"created_at":"2025-08-16T09:35:10.654Z","updated_at":"2025-08-16T09:35:10.654Z"},"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":279014547,"owners_count":26085536,"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","status":"online","status_checked_at":"2025-10-13T02:00:06.723Z","response_time":61,"last_error":null,"robots_txt_status":"success","robots_txt_updated_at":"2025-07-24T06:49:26.215Z","robots_txt_url":"https://github.com/robots.txt","online":true,"can_crawl_api":true,"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":["detect","detect-env","env","koa","koa2","node"],"created_at":"2024-11-25T16:28:09.783Z","updated_at":"2025-10-13T09:36:57.786Z","avatar_url":"https://github.com/Val-istar-Guo.png","language":"JavaScript","funding_links":[],"categories":[],"sub_categories":[],"readme":"# DETECT-ENV\n\n[![npm](https://img.shields.io/npm/v/detect-env.svg?style=flat-square)](https://www.npmjs.com/package/detect-env)\n[![npm](https://img.shields.io/npm/dm/detect-env.svg?style=flat-square)](https://www.npmjs.com/package/detect-env)\n\n## Install\n\n```\nnpm install detect-env\n```\n\n## Usage\n\n### Use default config\n\n```javascript\nimport env from 'detect-env';\n\nconst NEXT_PAGE_URL = env({\n  // if you want to set NET_PAGE_URL = 'prod.example.com'\n  // process.env.NODE_ENV can be 'prod' or 'production' according to alias setting\n  // but key's name mast be 'prod' according to alias setting\n  // if you want to change it, set alias to what you want\n  // for better performance, the neat code, the key name must be static\n  // rather than automatically correct according to the alias\n  prod: 'prod.example.com',\n  test: 'test.example.com',\n  default: 'dev.example.com',\n});\n\n// env.detect() is equal to env()\n// I recommend you use env.detect() because it is more readable\n// so you can write it as well\nconst NEXT_PAGE_URL = env.detect({\n  prod: 'prod.example.com',\n  test: 'test.example.com',\n  default: 'dev.example.com',\n});\n\n\n// Suppose process.env.NODE_ENV = 'prod'\nconsole.log(env.is.prod); // true\nconsole.log(env.is.dev); // false\nconsole.log(env.is.test); // false\nconsole.log(env.is.stage); // false\nconsole.log(env.is.local); // false\n\n\n// You no longer need to write these obscure code\nlet NEXT_PAGE_URL;\nswitch(process.env.NODE_ENV) {\n  case 'prod':\n    NEXT_PAGE_URL = 'prod.example.com';\n    break;\n  case 'test':\n    NEXT_PAGE_URL = 'test.example.com';\n    break;\n  default:\n    NEXT_PAGE_URL = 'dev.example.com';\n}\n\n// Also equal to\nconst NEXT_PAGE_URL = process.env.NODE_ENV === 'prod' ?\n  'prod.example.com' : process.env.NODE_ENV === 'test' ?\n  'test.example.com' : 'dev.example.com';\n\n// More example\nconst getGoodsPageUrl = env.detect({\n  prod: id =\u003e `prod.example.com?${id}`,\n  staging: id =\u003e `staging.example.com?${id}`,\n  default:id =\u003e `dev.example.com?${id}`,\n});\n```\n\n### Custom Config\n\n`Custom Config` can be use at `version \u003e= 2.0.0`.\nDefault config may not be able to meet everyone's needs.\nYou can custom alias, shortcut and env variable.\n\n```javascript\n// env.js\nimport { create } from 'detect-env';\n\n\nexport default create()\n  .alias({\n    // accept RegExp or function\n    // function must return true or false\n    prod: /^production$/,\n    dev: /^develop(ment)?$/,\n    stage: /^st$/,\n    local: (envName) =\u003e envName === undefined || envName === null || /(locale)|(^$)/.test(envName),\n    your_key: your_regexp_or_function,\n  })\n  .shortcut({\n    // The return value of the function will be used to set env.isProd\n    // if process.env.NODE_ENV = 'production'\n    // envName = 'prod' because alias setting\n    prod: (envName) =\u003e envName === 'prod',\n    stage: (envName) =\u003e envName === 'stage',\n    dev: (envName) =\u003e envName === 'dev',\n    test: (envName) =\u003e envName === 'test',\n    local: (envName) =\u003e envName === 'loacal',\n  })\n  .envVariable(() =\u003e process.env.NODE_ENV)\n  // also accept string\n  // .envVariable(process.env.NODE_ENV)\n```\n\nThen, you can use env in another file:\n\n```javascript\n// index.js\nimport env from './env';\n\nconst NEXT_PAGE_URL = env.detect({\n  prod: 'prod.example.com',\n  test: 'test.example.com',\n  default: 'dev.example.com',\n});\n```\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fval-istar-guo%2Fdetect-env","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fval-istar-guo%2Fdetect-env","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fval-istar-guo%2Fdetect-env/lists"}