Skip to content

a npm-scripts if/unless syntax using environment variable

Notifications You must be signed in to change notification settings

59naga/npm-statement

Repository files navigation

Npm Statement

Installation

npm install npm-statement --global

Usage

depending on the environment variable, can run the script.

export NODE_ENV=production
npm-if NODE_ENV is production then 'echo optimyze files...'
# optimyze files...

in addition can be run a local npm commands.

npm install eslint
npm-if NODE_ENV is production then 'eslint src' && echo pass
# pass

Syntaxes

npm-if VARIABLE trueScript
npm-if VARIABLE trueScript falseScript
npm-if VARIABLE then trueScript else falseScript
npm-if VARIABLE is {string|undefined} then trueScript else falseScript
npm-if VARIABLE is {string|undefined} then trueScript else falseScript
npm-if VARIABLE isnt {string|undefined} then trueScript else falseScript

npm-unless VARIABLE trueScript
npm-unless VARIABLE trueScript falseScript
npm-unless VARIABLE then trueScript else falseScript
npm-unless VARIABLE is {string|undefined} then trueScript else falseScript
npm-unless VARIABLE is {string|undefined} then trueScript else falseScript
npm-unless VARIABLE isnt {string|undefined} then trueScript else falseScript

Development

Requirement global

  • NodeJS v5.10.0
  • Npm v3.8.3
git clone https://github.com/59naga/npm-statement
cd npm-statement
npm install

npm test

License

MIT

About

a npm-scripts if/unless syntax using environment variable

Resources

Stars

Watchers

Forks

Packages

No packages published