Run commands that set environment variables across platforms
This micro-lib allows you to provide a script which sets an environment using unix style and have it work on windows too
I use this in my npm scripts:
Ultimately, the command that is executed (using
webpack --config build/webpack.config.js
NODE_ENV environment variable will be set by
Windows will choke when you set environment variables with
NODE_ENV=production like that. This makes it so you can
have a single command without worrying about setting the environment variable properly for the platform. Just set it
like you would if it's running on a unix system, and
cross-env will take care of setting it properly.
If you plan to do something like this:
cross-env FOO=bar && echo $FOO
And expect it to output
bar you're going to be sad, for two reasons:
FOOwill properly be set to
barin the first command, the
echo $FOOwill not.
echo $FOOruns, the
$FOOvariable is replaced with the variable value, before it's even passed to
cross-env(though, as indicated in #1, that doesn't happen anyway)
The main use case for this package is to simply run another script which will (itself) respond to the environment variable. These limitations are not a problem in that scenario (like in the example).
env-cmd - Reads environment variables from a file instead