A RetroSearch Logo

Home - News ( United States | United Kingdom | Italy | Germany ) - Football scores

Search Query:

Showing content from https://github.com/npm/cli/commit/6267f543c2ac134c0f8433f8b48659a3949bf210 below:

properly catch missing url opener error on interactive prompt (#… · npm/cli@6267f54 · GitHub

File tree Expand file treeCollapse file tree 3 files changed

+22

-4

lines changed

Filter options

Expand file treeCollapse file tree 3 files changed

+22

-4

lines changed Original file line number Diff line number Diff line change

@@ -1,5 +1,5 @@

1 1

const readline = require('readline')

2 -

const promiseSpawn = require('@npmcli/promise-spawn')

2 +

const open = require('./open-url.js')

3 3 4 4

function print (npm, title, url) {

5 5

const json = npm.config.get('json')

@@ -63,8 +63,7 @@ const promptOpen = async (npm, url, title, prompt, emitter) => {

63 63

return

64 64

}

65 65 66 -

const command = browser === true ? null : browser

67 -

await promiseSpawn.open(url, { command })

66 +

await open(npm, url, 'Browser unavailable. Please open the URL manually')

68 67

}

69 68 70 69

module.exports = promptOpen

Original file line number Diff line number Diff line change

@@ -5,6 +5,14 @@

5 5

* Make sure to inspect the output below. Do not ignore changes!

6 6

*/

7 7

'use strict'

8 +

exports[`test/lib/utils/open-url-prompt.js TAP does not error when opener can not find command > Outputs extra Browser unavailable message and url 1`] = `

9 +

npm home:

10 +

https://www.npmjs.com

11 +

Browser unavailable. Please open the URL manually:

12 +

https://www.npmjs.com

13 + 14 +

`

15 + 8 16

exports[`test/lib/utils/open-url-prompt.js TAP opens a url > must match snapshot 1`] = `

9 17

npm home:

10 18

https://www.npmjs.com

Original file line number Diff line number Diff line change

@@ -126,13 +126,24 @@ t.test('does not open url if canceled', async t => {

126 126 127 127

t.test('returns error when opener errors', async t => {

128 128

const { error, openerUrl } = await mockOpenUrlPrompt(t, {

129 -

openerResult: new Error('Opener failed'),

129 +

openerResult: Object.assign(new Error('Opener failed'), { code: 1 }),

130 130

})

131 131 132 132

t.match(error, /Opener failed/, 'got the correct error')

133 133

t.equal(openerUrl, 'https://www.npmjs.com', 'did not open')

134 134

})

135 135 136 +

t.test('does not error when opener can not find command', async t => {

137 +

const { OUTPUT, error, openerUrl } = await mockOpenUrlPrompt(t, {

138 +

// openerResult: new Error('Opener failed'),

139 +

openerResult: Object.assign(new Error('Opener failed'), { code: 127 }),

140 +

})

141 + 142 +

t.notOk(error, 'Did not error')

143 +

t.equal(openerUrl, 'https://www.npmjs.com', 'did not open')

144 +

t.matchSnapshot(OUTPUT, 'Outputs extra Browser unavailable message and url')

145 +

})

146 + 136 147

t.test('throws "canceled" error on SIGINT', async t => {

137 148

const emitter = new EventEmitter()

138 149

const { open } = await mockOpenUrlPrompt(t, {

You can’t perform that action at this time.


RetroSearch is an open source project built by @garambo | Open a GitHub Issue

Search and Browse the WWW like it's 1997 | Search results from DuckDuckGo

HTML: 3.2 | Encoding: UTF-8 | Version: 0.7.4