From e992b4a21ecdd96aa33c59682c0ac0cc8a30d776 Mon Sep 17 00:00:00 2001 From: Luke Karrys Date: Mon, 11 Apr 2022 12:25:06 -0700 Subject: [PATCH] fixup! fix: show more information during publish dry-run --- test/lib/commands/publish.js | 28 ++++++++++++++++++---------- 1 file changed, 18 insertions(+), 10 deletions(-) diff --git a/test/lib/commands/publish.js b/test/lib/commands/publish.js index e266ea524ccc0..64eb7c60cb062 100644 --- a/test/lib/commands/publish.js +++ b/test/lib/commands/publish.js @@ -227,6 +227,18 @@ t.test( ), }) + const npm = mockNpm({ + config: { 'dry-run': true, loglevel: 'info' }, + output: () => { + t.pass('output fn is called') + }, + }, t) + const registry = npm.config.get('registry') + npm.config.getCredentialsByURI = uri => { + t.same(uri, registry, 'gets credentials for expected registry') + return { /* no token will call log.warn */ } + } + const Publish = t.mock('../../../lib/commands/publish.js', { '../../../lib/utils/tar.js': { getContents: () => ({ @@ -235,6 +247,12 @@ t.test( logTar: () => { t.pass('logTar is called') }, + 'proc-log': { + warn (_, msg) { + t.match(msg, + `This command requires you to be logged in to ${registry} (dry-run)`) + }, + }, }, libnpmpublish: { publish: () => { @@ -242,16 +260,6 @@ t.test( }, }, }) - const npm = mockNpm({ - config: { 'dry-run': true, loglevel: 'info' }, - output: () => { - t.pass('output fn is called') - }, - }, t) - npm.config.getCredentialsByURI = uri => { - t.same(uri, npm.config.get('registry'), 'gets credentials for expected registry') - return { token: 'some.registry.token' } - } const publish = new Publish(npm)