Home

Awesome

You might actually want to look at my other utility cross-env. It's probably what you're really looking for :-)

argv-set-env

Status: npm version npm downloads Build Status Code Coverage js-standard-style

Use in your config files to set environment variables cross-platform.

Usage

I use this with my npm scripts:

{
  "scripts": {
    "build": "webpack --set-env-NODE_ENV=production",
    "test": "karma start --set-env-COVERAGE=true --set-env-NODE_ENV=test"
  }
}

And then in my webpack.config.js file, at the very top I do:

require('argv-set-env')()

Which in the case of build would set NODE_ENV to the string 'production' and in the case of test it would set NODE_ENV to the string 'test' and COVERAGE to the boolean true.

Options

You can optionally pass options:

require('argv-set-env')({
  // I'm setting these to the defaults here
  // you could set them to whatever you want
  env: process.env, // the object to have variables set on
  argv: process.argv, // the array of arguments which have the arguments defined
  prefix: '--set-env', // the prefix used in the array of arguments defining variables to set
})

LICENSE

MIT