diff options
Diffstat (limited to 'node_modules/npm-profile/lib/index.js')
-rw-r--r-- | node_modules/npm-profile/lib/index.js | 19 |
1 files changed, 10 insertions, 9 deletions
diff --git a/node_modules/npm-profile/lib/index.js b/node_modules/npm-profile/lib/index.js index aa322e37f..74a808429 100644 --- a/node_modules/npm-profile/lib/index.js +++ b/node_modules/npm-profile/lib/index.js @@ -4,13 +4,14 @@ const fetch = require('npm-registry-fetch') const { HttpErrorBase } = require('npm-registry-fetch/lib/errors') const os = require('os') const { URL } = require('url') +const log = require('proc-log') // try loginWeb, catch the "not supported" message and fall back to couch const login = (opener, prompter, opts = {}) => { const { creds } = opts return loginWeb(opener, opts).catch(er => { if (er instanceof WebLoginNotSupported) { - process.emit('log', 'verbose', 'web login not supported, trying couch') + log.verbose('web login not supported, trying couch') return prompter(creds) .then(data => loginCouch(data.username, data.password, opts)) } else { @@ -23,7 +24,7 @@ const adduser = (opener, prompter, opts = {}) => { const { creds } = opts return adduserWeb(opener, opts).catch(er => { if (er instanceof WebLoginNotSupported) { - process.emit('log', 'verbose', 'web adduser not supported, trying couch') + log.verbose('web adduser not supported, trying couch') return prompter(creds) .then(data => adduserCouch(data.username, data.email, data.password, opts)) } else { @@ -33,12 +34,12 @@ const adduser = (opener, prompter, opts = {}) => { } const adduserWeb = (opener, opts = {}) => { - process.emit('log', 'verbose', 'web adduser', 'before first POST') + log.verbose('web adduser', 'before first POST') return webAuth(opener, opts, { create: true }) } const loginWeb = (opener, opts = {}) => { - process.emit('log', 'verbose', 'web login', 'before first POST') + log.verbose('web login', 'before first POST') return webAuth(opener, opts, {}) } @@ -62,13 +63,13 @@ const webAuth = (opener, opts, body) => { return Promise.all([res, res.json()]) }).then(([res, content]) => { const { doneUrl, loginUrl } = content - process.emit('log', 'verbose', 'web auth', 'got response', content) + log.verbose('web auth', 'got response', content) if (!isValidUrl(doneUrl) || !isValidUrl(loginUrl)) { throw new WebLoginInvalidResponse('POST', res, content) } return content }).then(({ doneUrl, loginUrl }) => { - process.emit('log', 'verbose', 'web auth', 'opening url pair') + log.verbose('web auth', 'opening url pair') return opener(loginUrl).then( () => webAuthCheckLogin(doneUrl, { ...opts, cache: false }) ) @@ -121,7 +122,7 @@ const adduserCouch = (username, email, password, opts = {}) => { ...body, password: 'XXXXX', } - process.emit('log', 'verbose', 'adduser', 'before first PUT', logObj) + log.verbose('adduser', 'before first PUT', logObj) const target = '/-/user/org.couchdb.user:' + encodeURIComponent(username) return fetch.json(target, { @@ -147,9 +148,9 @@ const loginCouch = (username, password, opts = {}) => { ...body, password: 'XXXXX', } - process.emit('log', 'verbose', 'login', 'before first PUT', logObj) + log.verbose('login', 'before first PUT', logObj) - const target = '-/user/org.couchdb.user:' + encodeURIComponent(username) + const target = '/-/user/org.couchdb.user:' + encodeURIComponent(username) return fetch.json(target, { ...opts, method: 'PUT', |