🚀 Big News: Socket Acquires Coana to Bring Reachability Analysis to Every Appsec Team.Learn more
Socket
Sign inDemoInstall
Socket

cross-env-test

Package Overview
Dependencies
Maintainers
1
Versions
2
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

cross-env-test

Test environment variables across operating system environments

0.1.1
latest
Source
npm
Version published
Weekly downloads
82
-52.05%
Maintainers
1
Weekly downloads
 
Created
Source

cross-env-test

This command line tool works on *NIX (including OS X) and Windows. This tool checks to see if an environment variable is set to a given value:

cross-env-test NODE_ENV=testing

if NODE_ENV is set to testing the program will exit with 0 otherwise it will exit with a non-zero value

The logic is very close to:

if (process.env.NODE_ENV === 'testing') {
  process.exit(0);
} else {
  process.exit(1);
}

Usage I use this in my npm scripts:

{
  "scripts": {
    "postinstall": "cross-env-test NODE_ENV=testing || npm run build"
  }
}

Why?

Sometimes it's advantages to only run certain npm scripts sometimes. For example when running an install in an automated test environment.

Limitations

  • only supports '=' and '!=' operators
  • environment variable must be on the left hand side of the operator
  • arguments not in the form of lh=rh or lh!=rh will cause the program to exit with an error code
  • chained arguments are implicitly &&ed together
  • if there is interest we can add a --or modifier

License

MIT

Keywords

cross

FAQs

Package last updated on 06 Dec 2016

Did you know?

Socket

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.

Install

Related posts