Last active
August 15, 2019 06:17
-
-
Save dotherightthing/c255b22387d3a26400e8ba7b970effb8 to your computer and use it in GitHub Desktop.
[Passing command-line parameter to a gulpfile] #gulp
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/** | |
* Gulp Task Runner | |
*/ | |
var minimist = require('minimist'); | |
/** | |
* Command Line Configuration | |
* @example | |
* gulp dist | |
* | |
* @see https://github.com/gulpjs/gulp/blob/master/docs/recipes/pass-arguments-from-cli.md | |
* @see https://stackoverflow.com/questions/23023650/is-it-possible-to-pass-a-flag-to-gulp-to-have-it-run-tasks-in-different-ways | |
*/ | |
var knownOptions = { | |
string: 'pluginrole', | |
default: { pluginrole: process.env.NODE_ENV || 'parent' } | |
}; | |
var options = minimist(process.argv.slice(2), knownOptions); | |
if (options.pluginrole === 'child') { | |
// do something | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment