{"id":16181706,"url":"https://github.com/ericclemmons/if-env","last_synced_at":"2025-04-09T09:06:02.302Z","repository":{"id":56180773,"uuid":"48467621","full_name":"ericclemmons/if-env","owner":"ericclemmons","description":"Simplify npm scripts with `if-env ... \u0026\u0026 npm run this || npm run that`","archived":false,"fork":false,"pushed_at":"2020-11-22T10:39:15.000Z","size":7,"stargazers_count":97,"open_issues_count":6,"forks_count":11,"subscribers_count":3,"default_branch":"master","last_synced_at":"2025-04-02T06:07:50.131Z","etag":null,"topics":[],"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/ericclemmons.png","metadata":{"files":{"readme":"README.md","changelog":"CHANGELOG.md","contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null}},"created_at":"2015-12-23T03:46:39.000Z","updated_at":"2023-08-21T07:54:43.000Z","dependencies_parsed_at":"2022-08-15T14:10:43.148Z","dependency_job_id":null,"html_url":"https://github.com/ericclemmons/if-env","commit_stats":null,"previous_names":[],"tags_count":1,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/ericclemmons%2Fif-env","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/ericclemmons%2Fif-env/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/ericclemmons%2Fif-env/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/ericclemmons%2Fif-env/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/ericclemmons","download_url":"https://codeload.github.com/ericclemmons/if-env/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":248008629,"owners_count":21032556,"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":[],"created_at":"2024-10-10T06:26:48.521Z","updated_at":"2025-04-09T09:06:02.282Z","avatar_url":"https://github.com/ericclemmons.png","language":"JavaScript","funding_links":[],"categories":[],"sub_categories":[],"readme":"# if-env\n\n\u003e Simplify npm scripts with `if-env ... \u0026\u0026 npm run this || npm run that`\n\n- - -\n\n**I recommend switching to [`per-env`](https://github.com/ericclemmons/per-env), which is much simpler and much more powerful!**\n\n- - -\n\nSuppose you want to simplify development and be able to run `npm start`\nin all environments \u0026 run the correct scripts.\n\nYour `package.json` might look like this:\n\n```json\n\"scripts\": {\n  \"start\": \"if [[ ${NODE_ENV} == \\\"production\\\" ]]; then npm run start:prod; else npm run start:dev; fi\",\n  \"start:dev\": \"webpack\",\n  \"start:prod\": \"start-cluster\"\n}\n```\n\nThe problem is, this doesn't work in all environments.\n\nInstead, you can write:\n\n```json\n\"scripts\": {\n  \"start\": \"if-env NODE_ENV=production \u0026\u0026 npm run start:prod || npm run start:dev\",\n  \"start:dev\": \"webpack\",\n  \"start:prod\": \"start-cluster\"\n}\n```\n\n\n## Usage\n\n### 1. Install\n\n```shell\n$ npm install if-env --save\n```\n\n### 2. Add to `package.json`\n\n```json\n\"scripts\": {\n  \"start\": \"if-env SOME_ENV_VAR=some_val ANOTHER_ENV_VAR=another_val \u0026\u0026 npm run this || npm run that\"\n}\n```\n\n\n## License\n\n\u003e MIT \u0026copy; Eric Clemmons 2015\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fericclemmons%2Fif-env","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fericclemmons%2Fif-env","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fericclemmons%2Fif-env/lists"}