Giter VIP home page Giter VIP logo

cross-env-file's Introduction

cross-env-file

Run scripts that set environment across platforms via JSON file.

This is a fork of cross-env that uses a JSON file to read the environment variables.


Installation

This module is distributed via [npm][npm] which is bundled with [node][node] and should be installed as one of your project's devDependencies:

npm install --save-dev cross-env-file

Usage

I use this in your npm scripts:

{
  "scripts": {
    "build": "cross-env-file -p ./.my-env.json webpack --config build/webpack.config.js"
  }
}

Ultimately, the command that is executed (using [cross-spawn][cross-spawn]) is:

webpack --config build/webpack.config.js

If no path is specified with -p the default name .env is used.

This is how a JSON environment file could look like:

{
  "base_url": "https://example.com",
  "aws": {
    "my_secret": "my-nested-secret"
  }
}

This will add the following environment variables to process.env:

base_url=https://example.com
aws_my_secret=my-nested-secret

cross-env-file vs cross-env-file-shell

The cross-env-file module exposes two bins: cross-env-file and cross-env-file-shell. The first one executes commands using [cross-spawn][cross-spawn], while the second one uses the shell option from Node's spawn.

The main use case for cross-env-file-shell is when you need an environment variable to be set across an entire inline shell script, rather than just one command.

For example, if you want to have the environment variable apply to several commands in series then you will need to wrap those in quotes and use cross-env-file-shell instead of cross-env-file.

LICENSE

MIT

cross-env-file's People

Contributors

amilajack avatar anaisbetts avatar apidcloud avatar bennycode avatar bithavoc avatar compumike08 avatar danielo515 avatar danreylop avatar enzomartin avatar hgwood avatar igorklopov avatar inyono avatar jiangyuan avatar jnielson94 avatar marcioj avatar marcojakob avatar markwoon avatar mastilver avatar naholyr avatar nkbt avatar nogsmpls avatar nolanlawson avatar rgbkrk avatar sudo-suhas avatar thomasthiebaud avatar toddbluhm avatar turnerhayes avatar wopian avatar wtgtybhertgeghgtwtg avatar zhuangya avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.