Skip to content

Commit 7716e42

Browse files
Wicked7000isaacs
authored andcommitted
npmlog.notice the registry when using 'npm login'
PR-URL: #2075 Credit: @Wicked7000 Close: #2075 Reviewed-by: @isaacs Fixes: #2071
1 parent 8fa541a commit 7716e42

2 files changed

Lines changed: 15 additions & 1 deletion

File tree

lib/adduser.js

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@ const log = require('npmlog')
44
const npm = require('./npm.js')
55
const output = require('./utils/output.js')
66
const usageUtil = require('./utils/usage.js')
7+
const replaceInfo = require('./utils/replace-info.js')
78
const authTypes = {
89
legacy: require('./auth/legacy.js'),
910
oauth: require('./auth/oauth.js'),
@@ -57,6 +58,8 @@ const adduser = async (args) => {
5758

5859
log.disableProgress()
5960

61+
log.notice('', `Log in on ${replaceInfo(registry)}`)
62+
6063
const { message, newCreds } = await auth({
6164
creds,
6265
registry,

test/lib/adduser.js

Lines changed: 12 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,7 @@ const _flatOptions = {
1313

1414
let failSave = false
1515
let deletedConfig = {}
16+
let registryOutput = ''
1617
let setConfig = {}
1718
const authDummy = () => Promise.resolve({
1819
message: 'success',
@@ -32,7 +33,10 @@ const deleteMock = (key, where) => {
3233
}
3334
const adduser = requireInject('../../lib/adduser.js', {
3435
npmlog: {
35-
disableProgress: () => null
36+
disableProgress: () => null,
37+
notice: (_, msg) => {
38+
registryOutput = msg
39+
},
3640
},
3741
'../../lib/npm.js': {
3842
flatOptions: _flatOptions,
@@ -69,6 +73,12 @@ test('simple login', (t) => {
6973
adduser([], (err) => {
7074
t.ifError(err, 'npm adduser')
7175

76+
t.equal(
77+
registryOutput,
78+
'Log in on https://registry.npmjs.org/',
79+
'should have correct message result'
80+
)
81+
7282
t.deepEqual(
7383
deletedConfig,
7484
{
@@ -102,6 +112,7 @@ test('simple login', (t) => {
102112
'should output auth success msg'
103113
)
104114

115+
registryOutput = ''
105116
deletedConfig = {}
106117
setConfig = {}
107118
result = ''

0 commit comments

Comments
 (0)