You're Invited:Meet the Socket Team at BlackHat and DEF CON in Las Vegas, Aug 4-6.RSVP
Socket
Book a DemoInstallSign in
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
npmnpm
Version published
Weekly downloads
371
81.86%
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

SocketSocket SOC 2 Logo

Product

About

Packages

Stay in touch

Get open source security insights delivered straight into your inbox.

  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc

U.S. Patent No. 12,346,443 & 12,314,394. Other pending.