https://github.com/rendfall/npm-script-flags
NPM library that allows you to use flags in `npm run` command
https://github.com/rendfall/npm-script-flags
command-line npm script
Last synced: 4 months ago
JSON representation
NPM library that allows you to use flags in `npm run` command
- Host: GitHub
- URL: https://github.com/rendfall/npm-script-flags
- Owner: rendfall
- Created: 2016-04-27T22:33:29.000Z (over 9 years ago)
- Default Branch: master
- Last Pushed: 2016-05-02T21:34:46.000Z (over 9 years ago)
- Last Synced: 2024-04-26T10:03:21.895Z (almost 2 years ago)
- Topics: command-line, npm, script
- Language: JavaScript
- Size: 6.84 KB
- Stars: 3
- Watchers: 2
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
Awesome Lists containing this project
README
NPM Script flags
================
This is a library that allows you to use flags in `npm run` command.
Install
-------
`$ npm install npm-script-flags`
Why do we need extra library?
-----------------------------
In regards to documentation for use flags we need use `double dash` option:
`$ npm run gulp build -- --production`
Thanks to this library you can write just:
`$ npm run gulp build --production`
or even simpler:
`$ npm run gulp build -p`
Usage
-----
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
var Flags = require('npm-script-flags');
Flags.define('production-flag', {
longhand: 'production', // for `--production` handle
shorthand: 'p' // for `-p` handle
});
if (Flags.isFlag('production-flag')) {
// Flag is enabled so do something...
}
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
License
-------
MIT (http://www.opensource.org/licenses/mit-license.php)