diff options
author | isaacs <i@izs.me> | 2019-10-08 08:57:31 -0700 |
---|---|---|
committer | Myles Borins <mylesborins@google.com> | 2019-12-13 11:51:53 -0500 |
commit | f9b31edb25fcdf6602fbf8233affb791e2f849a5 (patch) | |
tree | 5e6c1818de1b32158c7f3c491bf2f87392e79ccb /deps/npm/lib/utils/open-url.js | |
parent | 0621e25f90c4b3bbea5b2e4f63b3ea919e47440c (diff) | |
download | node-new-f9b31edb25fcdf6602fbf8233affb791e2f849a5.tar.gz |
deps: update npm to 6.13.4
PR-URL: https://github.com/nodejs/node/pull/30904
Reviewed-By: Ruben Bridgewater <ruben@bridgewater.de>
Reviewed-By: Rich Trott <rtrott@gmail.com>
Reviewed-By: Jiawen Geng <technicalcute@gmail.com>
Reviewed-By: Michael Dawson <michael_dawson@ca.ibm.com>
Reviewed-By: Daijiro Wachi <daijiro.wachi@gmail.com>
Diffstat (limited to 'deps/npm/lib/utils/open-url.js')
-rw-r--r-- | deps/npm/lib/utils/open-url.js | 23 |
1 files changed, 21 insertions, 2 deletions
diff --git a/deps/npm/lib/utils/open-url.js b/deps/npm/lib/utils/open-url.js index 7a48d2e868..e1ed2b3fab 100644 --- a/deps/npm/lib/utils/open-url.js +++ b/deps/npm/lib/utils/open-url.js @@ -5,9 +5,28 @@ const opener = require('opener') // attempt to open URL in web-browser, print address otherwise: module.exports = function open (url, errMsg, cb, browser = npm.config.get('browser')) { - opener(url, { command: npm.config.get('browser') }, (er) => { + function printAlternateMsg () { + const json = npm.config.get('json') + const alternateMsg = json + ? JSON.stringify({ + title: errMsg, + url + }, null, 2) + : `${errMsg}:\n\n${url}` + + output(alternateMsg) + } + + const skipBrowser = process.argv.indexOf('--no-browser') > -1 + + if (skipBrowser) { + printAlternateMsg() + return cb() + } + + opener(url, { command: browser }, (er) => { if (er && er.code === 'ENOENT') { - output(`${errMsg}:\n\n${url}`) + printAlternateMsg() return cb() } else { return cb(er) |