Command line arguments
How to define options using command line arguments
Supposing you have a mocks
script added to your package.json
file, as seen in the get started chapter, then you can define options directly in the npm script using arguments:
{
"scripts": {
"mocks" : "mocks-server --path=./mocks --log=verbose --watch=false"
}
}
Or you can define options when calling to the npm command:
npm run mocks -- --delay=300
Note the usage of two double dashes. Anything after the first double dashes is not an option of npm, but a parameter for the script that npm executes.
Plugins options
Options added by registered plugins can be defined also using command line arguments. Supposing you have installed a plugin which adds a new option named language
, then you'll be able to run:
npm run mocks -- --language=es
Boolean options
For Boolean
options having a true
default value, use the --no-
. prefix for disabling them. (Read commander documentation for further info)
npm run mocks -- --no-watch --no-cli --no-corsPreFlight