{"id":22218580,"url":"https://github.com/megahertz/if-prod","last_synced_at":"2025-06-29T17:03:13.465Z","repository":{"id":57271451,"uuid":"146724064","full_name":"megahertz/if-prod","owner":"megahertz","description":"Conditional running of npm scripts depending on environment","archived":false,"fork":false,"pushed_at":"2018-08-30T12:34:07.000Z","size":4,"stargazers_count":3,"open_issues_count":0,"forks_count":0,"subscribers_count":2,"default_branch":"master","last_synced_at":"2025-06-29T17:01:58.262Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":null,"language":"Shell","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":null,"status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/megahertz.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":null,"code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null}},"created_at":"2018-08-30T09:03:35.000Z","updated_at":"2023-03-17T12:12:53.000Z","dependencies_parsed_at":"2022-09-01T00:43:11.297Z","dependency_job_id":null,"html_url":"https://github.com/megahertz/if-prod","commit_stats":null,"previous_names":[],"tags_count":0,"template":false,"template_full_name":null,"purl":"pkg:github/megahertz/if-prod","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/megahertz%2Fif-prod","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/megahertz%2Fif-prod/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/megahertz%2Fif-prod/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/megahertz%2Fif-prod/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/megahertz","download_url":"https://codeload.github.com/megahertz/if-prod/tar.gz/refs/heads/master","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/megahertz%2Fif-prod/sbom","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":262632280,"owners_count":23340209,"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-12-02T22:27:11.310Z","updated_at":"2025-06-29T17:03:13.417Z","avatar_url":"https://github.com/megahertz.png","language":"Shell","funding_links":[],"categories":[],"sub_categories":[],"readme":"# if-prod\n[![Build Status](https://travis-ci.org/megahertz/if-prod.svg?branch=master)](https://travis-ci.org/megahertz/if-prod)\n[![NPM version](https://badge.fury.io/js/if-prod.svg)](https://badge.fury.io/js/if-prod)\n[![Dependencies status](https://david-dm.org/megahertz/if-prod/status.svg)](https://david-dm.org/megahertz/if-prod)\n\n## Description\n\nThis tiny script allows to simplify conditional statements which check\nfor the current environment from $NODE_ENV. Consider the following\npackage.json:\n\n```json\n\"scripts\": {\n  \"start\": \"if [[ \\\"${NODE_ENV}\\\" == \\\"production\\\" ]]; then node dist/server.js; else webpack --watch; fi\",\n}\n```\n\nThe following code is hard for reading and doesn't work on Windows. It\ncan be simplified using this package:\n\n```json\n\"scripts\": {\n  \"start\": \"if-prod \u0026\u0026 node dist/server.js || webpack --watch\",\n}\n```\n\n## Installation\n\nInstall with [npm](https://npmjs.org/package/if-prod):\n\n    npm install if-prod\n\n## Usage\n\nThere are the following commands in this package:\n\n - if-prod\n - if-dev\n - if-env-is ENVIRONMENT NAME\n - if-not-prod\n - if-not-dev\n - if-not-env-is ENVIRONMENT NAME\n\n### Examples\n\n- **if/then/else**\n  `if-prod \u0026\u0026 node dist/server.js || webpack --watch`\n\n- **single if**\n  `if-prod \u0026\u0026 node dist/server.js || true` - without `|| true` this\n  command returns status code 1 if the current environment is\n  not \"production\"\n\n- **if not**\n  `if-not-prod \u0026\u0026 rm -rf dist || true` - run in all environment except\n  \"production\"\n\n- **custom environment**\n  `if-env-is test \u0026\u0026 rm -rf coverage || true`\n\n## Related projects\n\n[ericclemmons/if-env](https://github.com/ericclemmons/if-env) - almost\nthe same approach but can check for any environment variables, not only\n$NODE_ENV\n\n[ericclemmons/per-env](https://github.com/ericclemmons/per-env) -\nenvironment-driven npm scripting\n\n## License\n\nLicensed under MIT.\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fmegahertz%2Fif-prod","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fmegahertz%2Fif-prod","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fmegahertz%2Fif-prod/lists"}