GithubHelp home page GithubHelp logo

nogsmpls / cross-env Goto Github PK

View Code? Open in Web Editor NEW

This project forked from kentcdodds/cross-env

0.0 2.0 0.0 83 KB

Cross platform setting of environment scripts

License: MIT License

JavaScript 100.00%

cross-env's Introduction

cross-env

Status: npm version npm downloads Build Status Code Coverage

This micro-lib allows you to provide a script which sets an environment using unix style and have it work on windows too

Usage

I use this in my npm scripts:

{
  "scripts": {
    "build": "cross-env NODE_ENV=production webpack --config build/webpack.config.js"
  }
}

Ultimately, the command that is executed (using spawn) is:

webpack --config build/webpack.config.js

The NODE_ENV environment variable will be set by cross-env

Why?

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.

Known limitations

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:

  1. Technically, those will run as two separate commands, so even though FOO will properly be set to bar in the first command, the echo $FOO will not.
  2. When echo $FOO runs, the $FOO variable 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).

LICENSE

MIT

cross-env's People

Watchers

 avatar  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.