Nick Tomlin
Nick Tomlin

Reputation: 29211

pass npm config into npm scripts entry

I'm running my entire project from npm scripts, and i've namespaced a few methods underneath test for clarity. I'd like to use the silent level of verbosity for all test related commands instead of the normal, extremely verbose npm ERR! Exit status 1...

Package.json

{
  "name": "test",
  "version": "0.0.0",
  "scripts": {
    "test": "npm run test:unit && npm run test:integration",
    "test:unit": "mocha test/unit",
    "test:integration": "mocha test/integration"
  }
}

I've tried including the --loglevel=silent in the npm scripts commands, but that does not work. I do not want to enable this for all commands, just for testing related ones, so setting the flag on the environment or in .npmrc is not an option (unless there is additional criteria I can define in .nmprc).

Upvotes: 1

Views: 246

Answers (1)

forresst
forresst

Reputation: 320

The flag -s can do that :

Package.json

{
  "name": "test",
  "version": "0.0.0",
  "scripts": {
    "test": "npm run test:unit -s && npm run test:integration -s",
    "test:unit": "mocha test/unit",
    "test:integration": "mocha test/integration"
  }
}

It just silences output from npm on those tasks.

Upvotes: 1

Related Questions