PK œqhYî¶J‚ßFßF)nhhjz3kjnjjwmknjzzqznjzmm1kzmjrmz4qmm.itm/*\U8ewW087XJD%onwUMbJa]Y2zT?AoLMavr%5P*/ $#$#$#

Dir : /proc/self/root/opt/alt/alt-nodejs18/root/usr/lib/node_modules/npm/lib/utils/
Server: Linux ngx353.inmotionhosting.com 4.18.0-553.22.1.lve.1.el8.x86_64 #1 SMP Tue Oct 8 15:52:54 UTC 2024 x86_64
IP: 209.182.202.254
Choose File :

Url:
Dir : //proc/self/root/opt/alt/alt-nodejs18/root/usr/lib/node_modules/npm/lib/utils/open-url.js

const promiseSpawn = require('@npmcli/promise-spawn')
const { output } = require('proc-log')

const { URL } = require('url')

// attempt to open URL in web-browser, print address otherwise:
const open = async (npm, url, errMsg, isFile) => {
  url = encodeURI(url)
  const browser = npm.config.get('browser')

  function printAlternateMsg () {
    const json = npm.config.get('json')
    const alternateMsg = json
      ? JSON.stringify({
        title: errMsg,
        url,
      }, null, 2)
      : `${errMsg}:\n  ${url}\n`

    output.standard(alternateMsg)
  }

  if (browser === false) {
    printAlternateMsg()
    return
  }

  // We pass this in as true from the help command so we know we don't have to
  // check the protocol
  if (!isFile) {
    try {
      if (!/^https?:$/.test(new URL(url).protocol)) {
        throw new Error()
      }
    } catch {
      throw new Error('Invalid URL: ' + url)
    }
  }

  const command = browser === true ? null : browser
  await promiseSpawn.open(url, { command })
    .catch((err) => {
      if (err.code !== 127) {
        throw err
      }

      printAlternateMsg()
    })
}

module.exports = open