Skip to content

Commit

Permalink
npmlog.notice the registry when using 'npm login'
Browse files Browse the repository at this point in the history
PR-URL: #2075
Credit: @Wicked7000
Close: #2075
Reviewed-by: @isaacs

Fixes: #2071
  • Loading branch information
Wicked7000 authored and isaacs committed Nov 6, 2020
1 parent 8fa541a commit 7716e42
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 1 deletion.
3 changes: 3 additions & 0 deletions lib/adduser.js
Original file line number Diff line number Diff line change
Expand Up @@ -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'),
Expand Down Expand Up @@ -57,6 +58,8 @@ const adduser = async (args) => {

log.disableProgress()

log.notice('', `Log in on ${replaceInfo(registry)}`)

const { message, newCreds } = await auth({
creds,
registry,
Expand Down
13 changes: 12 additions & 1 deletion test/lib/adduser.js
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@ const _flatOptions = {

let failSave = false
let deletedConfig = {}
let registryOutput = ''
let setConfig = {}
const authDummy = () => Promise.resolve({
message: 'success',
Expand All @@ -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,
Expand Down Expand Up @@ -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,
{
Expand Down Expand Up @@ -102,6 +112,7 @@ test('simple login', (t) => {
'should output auth success msg'
)

registryOutput = ''
deletedConfig = {}
setConfig = {}
result = ''
Expand Down

0 comments on commit 7716e42

Please sign in to comment.