From b018eb84266dc5a02274849135ca148cb59cc349 Mon Sep 17 00:00:00 2001 From: Gar Date: Wed, 17 Feb 2021 14:57:38 -0800 Subject: [PATCH] fix(runScript): obey silent loglevel If the user has specified a silent loglevel, we should pass that intention on when we call runScript Also a small cleanup in lib/run-script.js so that the reference to @npmcli/run-script is named the same as other files. PR-URL: https://github.com/npm/cli/pull/2719 Credit: @wraithgar Close: #2719 Reviewed-by: @nlf --- lib/ci.js | 1 + lib/install.js | 1 + lib/publish.js | 3 +++ lib/run-script.js | 10 +++++----- 4 files changed, 10 insertions(+), 5 deletions(-) diff --git a/lib/ci.js b/lib/ci.js index 36410616fb9bf..80b9dbb223648 100644 --- a/lib/ci.js +++ b/lib/ci.js @@ -68,6 +68,7 @@ const ci = async () => { scriptShell, stdio: 'inherit', stdioString: true, + banner: log.level !== 'silent', event, }) } diff --git a/lib/install.js b/lib/install.js index 303370594a062..d4ee7047f746f 100644 --- a/lib/install.js +++ b/lib/install.js @@ -57,6 +57,7 @@ const install = async args => { scriptShell, stdio: 'inherit', stdioString: true, + banner: log.level !== 'silent', event, }) } diff --git a/lib/publish.js b/lib/publish.js index 190d381a8aeeb..3e8df0076efa2 100644 --- a/lib/publish.js +++ b/lib/publish.js @@ -85,6 +85,7 @@ const publish_ = async (arg, opts) => { path: spec.fetchSpec, stdio: 'inherit', pkg: manifest, + banner: log.level !== 'silent', }) } @@ -121,6 +122,7 @@ const publish_ = async (arg, opts) => { path: spec.fetchSpec, stdio: 'inherit', pkg: manifest, + banner: log.level !== 'silent', }) await runScript({ @@ -128,6 +130,7 @@ const publish_ = async (arg, opts) => { path: spec.fetchSpec, stdio: 'inherit', pkg: manifest, + banner: log.level !== 'silent', }) } diff --git a/lib/run-script.js b/lib/run-script.js index 7aab07f5daebd..8e24a8a44e99d 100644 --- a/lib/run-script.js +++ b/lib/run-script.js @@ -1,5 +1,5 @@ -const run = require('@npmcli/run-script') -const { isServerPackage } = run +const runScript = require('@npmcli/run-script') +const { isServerPackage } = runScript const npm = require('./npm.js') const readJson = require('read-package-json-fast') const { resolve } = require('path') @@ -27,11 +27,11 @@ const completion = async (opts, cb) => { } const cmd = (args, cb) => { - const fn = args.length ? runScript : list + const fn = args.length ? doRun : list return fn(args).then(() => cb()).catch(cb) } -const runScript = async (args) => { +const doRun = async (args) => { const path = npm.localPrefix const event = args.shift() const { scriptShell } = npm.flatOptions @@ -76,7 +76,7 @@ const runScript = async (args) => { } for (const [event, args] of events) { - await run({ + await runScript({ ...opts, event, args,