diff --git a/lib/auth/sso.js b/lib/auth/sso.js index ca8c501684c29..e795545ecaf68 100644 --- a/lib/auth/sso.js +++ b/lib/auth/sso.js @@ -13,7 +13,7 @@ const log = require('npmlog') const profile = require('npm-profile') const npmFetch = require('npm-registry-fetch') -const openUrl = promisify(require('../utils/open-url.js')) +const openUrl = require('../utils/open-url.js') const otplease = require('../utils/otplease.js') const pollForSession = ({ registry, token, opts }) => { diff --git a/lib/repo.js b/lib/repo.js index 60fe6dbaf90b9..f0be99d4d69e9 100644 --- a/lib/repo.js +++ b/lib/repo.js @@ -1,10 +1,9 @@ const log = require('npmlog') const pacote = require('pacote') const { URL } = require('url') -const { promisify } = require('util') const hostedFromMani = require('./utils/hosted-git-info-from-manifest.js') -const openUrl = promisify(require('./utils/open-url.js')) +const openUrl = require('./utils/open-url.js') const usageUtil = require('./utils/usage.js') class Repo { diff --git a/test/lib/auth/sso.js b/test/lib/auth/sso.js index 9d77e7c274025..dbf42ff62afa5 100644 --- a/test/lib/auth/sso.js +++ b/test/lib/auth/sso.js @@ -22,15 +22,12 @@ const sso = requireInject('../../../lib/auth/sso.js', { }, 'npm-profile': profile, 'npm-registry-fetch': npmFetch, - '../../../lib/utils/open-url.js': (npm, url, msg, cb) => { - if (url) - cb() - else { - cb(Object.assign( + '../../../lib/utils/open-url.js': async (npm, url, msg) => { + if (!url) + throw Object.assign( new Error('failed open url'), { code: 'ERROR' } - )) - } + ) }, '../../../lib/utils/otplease.js': (opts, fn) => { if (opts) diff --git a/test/lib/repo.js b/test/lib/repo.js index 7abda55ca28d0..9c22bbaea340b 100644 --- a/test/lib/repo.js +++ b/test/lib/repo.js @@ -108,10 +108,9 @@ const pacote = { // keep a tally of which urls got opened const opened = {} -const openUrl = async (npm, url, errMsg, cb) => { +const openUrl = async (npm, url, errMsg) => { opened[url] = opened[url] || 0 opened[url]++ - process.nextTick(cb) } const Repo = requireInject('../../lib/repo.js', {