From 7716e423ee92a81730c0dfe5b9ecb4bb41a3f947 Mon Sep 17 00:00:00 2001 From: Jason Attwood Date: Wed, 28 Oct 2020 22:57:08 +0000 Subject: [PATCH] npmlog.notice the registry when using 'npm login' PR-URL: https://github.com/npm/cli/pull/2075 Credit: @Wicked7000 Close: #2075 Reviewed-by: @isaacs Fixes: #2071 --- lib/adduser.js | 3 +++ test/lib/adduser.js | 13 ++++++++++++- 2 files changed, 15 insertions(+), 1 deletion(-) diff --git a/lib/adduser.js b/lib/adduser.js index 895a677c019de..5017f57a8ae90 100644 --- a/lib/adduser.js +++ b/lib/adduser.js @@ -4,6 +4,7 @@ const log = require('npmlog') const npm = require('./npm.js') const output = require('./utils/output.js') const usageUtil = require('./utils/usage.js') +const replaceInfo = require('./utils/replace-info.js') const authTypes = { legacy: require('./auth/legacy.js'), oauth: require('./auth/oauth.js'), @@ -57,6 +58,8 @@ const adduser = async (args) => { log.disableProgress() + log.notice('', `Log in on ${replaceInfo(registry)}`) + const { message, newCreds } = await auth({ creds, registry, diff --git a/test/lib/adduser.js b/test/lib/adduser.js index 4d2233b18ce6c..22c7c49cfaeaf 100644 --- a/test/lib/adduser.js +++ b/test/lib/adduser.js @@ -13,6 +13,7 @@ const _flatOptions = { let failSave = false let deletedConfig = {} +let registryOutput = '' let setConfig = {} const authDummy = () => Promise.resolve({ message: 'success', @@ -32,7 +33,10 @@ const deleteMock = (key, where) => { } const adduser = requireInject('../../lib/adduser.js', { npmlog: { - disableProgress: () => null + disableProgress: () => null, + notice: (_, msg) => { + registryOutput = msg + }, }, '../../lib/npm.js': { flatOptions: _flatOptions, @@ -69,6 +73,12 @@ test('simple login', (t) => { adduser([], (err) => { t.ifError(err, 'npm adduser') + t.equal( + registryOutput, + 'Log in on https://registry.npmjs.org/', + 'should have correct message result' + ) + t.deepEqual( deletedConfig, { @@ -102,6 +112,7 @@ test('simple login', (t) => { 'should output auth success msg' ) + registryOutput = '' deletedConfig = {} setConfig = {} result = ''