Skip to content

Commit 0f652a0

Browse files
committed
fix(repo, auth.sso): don't promisify open-url
This causes a `cb() not called` error as the promisified function explodes silently.
1 parent bd2545d commit 0f652a0

File tree

4 files changed

+7
-12
lines changed

4 files changed

+7
-12
lines changed

lib/auth/sso.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@ const log = require('npmlog')
1313
const profile = require('npm-profile')
1414
const npmFetch = require('npm-registry-fetch')
1515

16-
const openUrl = promisify(require('../utils/open-url.js'))
16+
const openUrl = require('../utils/open-url.js')
1717
const otplease = require('../utils/otplease.js')
1818

1919
const pollForSession = ({ registry, token, opts }) => {

lib/repo.js

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,9 @@
11
const log = require('npmlog')
22
const pacote = require('pacote')
33
const { URL } = require('url')
4-
const { promisify } = require('util')
54

65
const hostedFromMani = require('./utils/hosted-git-info-from-manifest.js')
7-
const openUrl = promisify(require('./utils/open-url.js'))
6+
const openUrl = require('./utils/open-url.js')
87
const usageUtil = require('./utils/usage.js')
98

109
class Repo {

test/lib/auth/sso.js

Lines changed: 4 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -22,15 +22,12 @@ const sso = requireInject('../../../lib/auth/sso.js', {
2222
},
2323
'npm-profile': profile,
2424
'npm-registry-fetch': npmFetch,
25-
'../../../lib/utils/open-url.js': (npm, url, msg, cb) => {
26-
if (url)
27-
cb()
28-
else {
29-
cb(Object.assign(
25+
'../../../lib/utils/open-url.js': async (npm, url, msg) => {
26+
if (!url)
27+
throw Object.assign(
3028
new Error('failed open url'),
3129
{ code: 'ERROR' }
32-
))
33-
}
30+
)
3431
},
3532
'../../../lib/utils/otplease.js': (opts, fn) => {
3633
if (opts)

test/lib/repo.js

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -108,10 +108,9 @@ const pacote = {
108108

109109
// keep a tally of which urls got opened
110110
const opened = {}
111-
const openUrl = async (npm, url, errMsg, cb) => {
111+
const openUrl = async (npm, url, errMsg) => {
112112
opened[url] = opened[url] || 0
113113
opened[url]++
114-
process.nextTick(cb)
115114
}
116115

117116
const Repo = requireInject('../../lib/repo.js', {

0 commit comments

Comments
 (0)