Skip to main content
Version: 1.9.0

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 registered a plugin which add a new option called "language", then you'll be able to run:

npm run mocks -- --language=Es-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-adminApiDeprecatedPaths