Skip to content

Commit 9600664

Browse files
wraithgarruyadorno
authored andcommittedMar 4, 2021
fix(repo, auth.sso): don't promisify open-url
This causes a `cb() not called` error as the promisified function explodes silently. PR-URL: #2824 Credit: @wraithgar Close: #2824 Reviewed-by: @ruyadorno
1 parent 1efdd96 commit 9600664

File tree

4 files changed

+7
-13
lines changed

4 files changed

+7
-13
lines changed
 

‎lib/auth/sso.js

+1-3
Original file line numberDiff line numberDiff line change
@@ -7,13 +7,11 @@
77
// CLI, we can remove this, and fold the lib/auth/legacy.js back into
88
// lib/adduser.js
99

10-
const { promisify } = require('util')
11-
1210
const log = require('npmlog')
1311
const profile = require('npm-profile')
1412
const npmFetch = require('npm-registry-fetch')
1513

16-
const openUrl = promisify(require('../utils/open-url.js'))
14+
const openUrl = require('../utils/open-url.js')
1715
const otplease = require('../utils/otplease.js')
1816

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

‎lib/repo.js

+1-2
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

+4-6
Original file line numberDiff line numberDiff line change
@@ -22,14 +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-
))
30+
)
3331
}
3432
},
3533
'../../../lib/utils/otplease.js': (opts, fn) => {

‎test/lib/repo.js

+1-2
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)
Please sign in to comment.