This may be a super silly question:
I have a gulp task in my gulpfile called start and in my package.json I have a script:
"start": "gulp start",
I would like to call this from the command line like npm start staging and use the staging argument inside the start task to determine the env. This of course produces an error:
Task never defined: staging
I was able to get around it by adding a bogus flag:
"start": "gulp start --junkFlag"
This now works correctly and I can access staging from the args list.
However,
a) I'm not sure why this works, and I don't like comitting code I don't understand
b) It is extraordinarily hacky :(
@stclairdaniel Gulp (gulp-cli) treats non-flag args as task name, but not about flags and flag values. To separate non-flag args and flags/flag values, gulp-cli uses yargs. So please check yargs's document.
About npm's "script" field, please check npm's documents.
This may be a super silly question: I have a gulp task in my gulpfile called
start
and in mypackage.json
I have a script:"start": "gulp start",
I would like to call this from the command line like
npm start staging
and use thestaging
argument inside thestart
task to determine the env. This of course produces an error:Task never defined: staging
I was able to get around it by adding a bogus flag:
"start": "gulp start --junkFlag"
This now works correctly and I can accessstaging
from the args list.However, a) I'm not sure why this works, and I don't like comitting code I don't understand b) It is extraordinarily hacky :(
I would appreciate any advice!