
Product
Introducing Socket Firewall Enterprise: Flexible, Configurable Protection for Modern Package Ecosystems
Socket Firewall Enterprise is now available with flexible deployment, configurable policies, and expanded language support.
@datorama/if-env
Advanced tools
Simplify npm scripts with "if-env ... && npm run this || npm run that"
Simplify npm scripts with
if-env ... && npm run this || npm run that
I recommend switching to per-env, which is much simpler and much more powerful!
Suppose you want to simplify development and be able to run npm start
in all environments & run the correct scripts.
Your package.json might look like this:
"scripts": {
"start": "if [[ ${NODE_ENV} == \"production\" ]]; then npm run start:prod; else npm run start:dev; fi",
"start:dev": "webpack",
"start:prod": "start-cluster"
}
The problem is, this doesn't work in all environments.
Instead, you can write:
"scripts": {
"start": "if-env NODE_ENV=production && npm run start:prod || npm run start:dev",
"start:dev": "webpack",
"start:prod": "start-cluster"
}
$ npm install if-env --save
package.json"scripts": {
"start": "if-env SOME_ENV_VAR=some_val ANOTHER_ENV_VAR=another_val && npm run this || npm run that"
}
MIT © Eric Clemmons 2015
1.0.0 (2015-12-22)
Implemented enhancements:
* This Change Log was automatically generated by github_changelog_generator
FAQs
Simplify npm scripts with "if-env ... && npm run this || npm run that"
We found that @datorama/if-env demonstrated a not healthy version release cadence and project activity because the last version was released a year ago. It has 1 open source maintainer collaborating on the project.
Did you know?

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Product
Socket Firewall Enterprise is now available with flexible deployment, configurable policies, and expanded language support.

Security News
Open source dashboard CNAPulse tracks CVE Numbering Authorities’ publishing activity, highlighting trends and transparency across the CVE ecosystem.

Product
Detect malware, unsafe data flows, and license issues in GitHub Actions with Socket’s new workflow scanning support.