Skip to content

Commit

Permalink
fix(repo, auth.sso): don't promisify open-url
Browse files Browse the repository at this point in the history
This causes a `cb() not called` error as the promisified
function explodes silently.
  • Loading branch information
wraithgar committed Mar 4, 2021
1 parent bd2545d commit a7aa751
Show file tree
Hide file tree
Showing 4 changed files with 7 additions and 13 deletions.
4 changes: 1 addition & 3 deletions lib/auth/sso.js
Original file line number Diff line number Diff line change
Expand Up @@ -7,13 +7,11 @@
// CLI, we can remove this, and fold the lib/auth/legacy.js back into
// lib/adduser.js

const { promisify } = require('util')

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 }) => {
Expand Down
3 changes: 1 addition & 2 deletions lib/repo.js
Original file line number Diff line number Diff line change
@@ -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 {
Expand Down
10 changes: 4 additions & 6 deletions test/lib/auth/sso.js
Original file line number Diff line number Diff line change
Expand Up @@ -22,14 +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) => {
Expand Down
3 changes: 1 addition & 2 deletions test/lib/repo.js
Original file line number Diff line number Diff line change
Expand Up @@ -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', {
Expand Down

0 comments on commit a7aa751

Please sign in to comment.