0

Is it possible to send command line arguments to npm scripts? This is what I need:

"test": "npm run test:build && npm run -s test:run",
"test:build": "rollup -c myArgument",
"test:run": "karma start"

and myArgument defines the --environment, ex. (rollup -c --environment TEST).

I am using npm version 3.10.10.

EDIT: I want to know how it is possible when you run the "npm run test" NOT the "npm run test:build" the "npm test" runs the "test:build" and "test:run"

GeoCom
  • 1,290
  • 2
  • 12
  • 33
  • `npm run test:build -- --environment test` would pass the additional `environment` parameter to the script being called, not sure how many levels of calling you can do it through. – jonrsharpe Oct 02 '17 at 10:28
  • Possible duplicate of [Sending command line arguments to npm script](https://stackoverflow.com/questions/11580961/sending-command-line-arguments-to-npm-script) – jonrsharpe Oct 02 '17 at 10:30
  • @jonrsharpe you answer works when you run the npm test:build. But I need to run with npm test. See the updatd question – GeoCom Oct 02 '17 at 11:55
  • have you tried env variable like $MYARGUMENT – Panos K Oct 02 '17 at 12:03
  • The duplicate also covers that; that’s what I meant by levels of calling. `ROLLUP_ENV=test npm run test` or something. – jonrsharpe Oct 02 '17 at 12:17

0 Answers0