(npm, url, title, isFile)
| 25 | |
| 26 | // attempt to open URL in web-browser, print address otherwise: |
| 27 | const openUrl = async (npm, url, title, isFile) => { |
| 28 | url = encodeURI(url) |
| 29 | const browser = npm.config.get('browser') |
| 30 | const json = npm.config.get('json') |
| 31 | |
| 32 | if (browser === false) { |
| 33 | outputMsg(json, title, url) |
| 34 | return |
| 35 | } |
| 36 | |
| 37 | // We pass this in as true from the help command so we know we don't have to check the protocol |
| 38 | if (!isFile) { |
| 39 | assertValidUrl(url) |
| 40 | } |
| 41 | |
| 42 | try { |
| 43 | await input.start(() => open(url, { |
| 44 | command: browser === true ? null : browser, |
| 45 | })) |
| 46 | } catch (err) { |
| 47 | if (err.code !== 127) { |
| 48 | throw err |
| 49 | } |
| 50 | outputMsg(json, title, url) |
| 51 | } |
| 52 | } |
| 53 | |
| 54 | // Prompt to open URL in browser if possible |
| 55 | const openUrlPrompt = async (npm, url, title, prompt, { signal }) => { |
no test coverage detected
searching dependent graphs…