GithubHelp home page GithubHelp logo

handtrix / if-env Goto Github PK

View Code? Open in Web Editor NEW

This project forked from ericclemmons/if-env

0.0 2.0 0.0 7 KB

Simplify npm scripts with `if-env ... && npm run this || npm run that`

License: MIT License

JavaScript 100.00%

if-env's Introduction

if-env

Simplify npm scripts with if-env ... && npm run this || npm run that


I recommend switching to per-env, which is much simpler and much more powerful!


Suppose you want to simplify development and be able to run npm start in all environments & run the correct scripts.

Your package.json might look like this:

"scripts": {
  "start": "if [[ ${NODE_ENV} == \"production\" ]]; then npm run start:prod; else npm run start:dev; fi",
  "start:dev": "webpack",
  "start:prod": "start-cluster"
}

The problem is, this doesn't work in all environments.

Instead, you can write:

"scripts": {
  "start": "if-env NODE_ENV=production && npm run start:prod || npm run start:dev",
  "start:dev": "webpack",
  "start:prod": "start-cluster"
}

Usage

1. Install

$ npm install if-env --save

2. Add to package.json

"scripts": {
  "start": "if-env SOME_ENV_VAR=some_val ANOTHER_ENV_VAR=another_val && npm run this || npm run that"
}

License

MIT © Eric Clemmons 2015

if-env's People

Contributors

ericclemmons avatar handtrix avatar loris avatar

Watchers

James Cloos 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.