Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Ouput registry information before prompting user for login information #2075

Closed
wants to merge 3 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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