Security News
Research
Data Theft Repackaged: A Case Study in Malicious Wrapper Packages on npm
The Socket Research Team breaks down a malicious wrapper package that uses obfuscation to harvest credentials and exfiltrate sensitive data.
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
FAQs
Simplify npm scripts with "if-env ... && npm run this || npm run that"
We found that 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.
Security News
Research
The Socket Research Team breaks down a malicious wrapper package that uses obfuscation to harvest credentials and exfiltrate sensitive data.
Research
Security News
Attackers used a malicious npm package typosquatting a popular ESLint plugin to steal sensitive data, execute commands, and exploit developer systems.
Security News
The Ultralytics' PyPI Package was compromised four times in one weekend through GitHub Actions cache poisoning and failure to rotate previously compromised API tokens.