MCPcopy Index your code
hub / github.com/nodejs/node / openUrl

Function openUrl

deps/npm/lib/utils/open-url.js:27–52  ·  view source on GitHub ↗
(npm, url, title, isFile)

Source from the content-addressed store, hash-verified

25
26// attempt to open URL in web-browser, print address otherwise:
27const 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
55const openUrlPrompt = async (npm, url, title, prompt, { signal }) => {

Callers 4

openUrlPromptFunction · 0.70
execMethod · 0.50
viewManMethod · 0.50
openFundingUrlMethod · 0.50

Calls 5

outputMsgFunction · 0.85
assertValidUrlFunction · 0.85
getMethod · 0.65
openFunction · 0.50
startMethod · 0.45

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…