diff options
Diffstat (limited to 'deps/npm/lib/utils/open-url.js')
-rw-r--r-- | deps/npm/lib/utils/open-url.js | 16 |
1 files changed, 16 insertions, 0 deletions
diff --git a/deps/npm/lib/utils/open-url.js b/deps/npm/lib/utils/open-url.js new file mode 100644 index 0000000000..7a48d2e868 --- /dev/null +++ b/deps/npm/lib/utils/open-url.js @@ -0,0 +1,16 @@ +'use strict' +const npm = require('../npm.js') +const output = require('./output.js') +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) => { + if (er && er.code === 'ENOENT') { + output(`${errMsg}:\n\n${url}`) + return cb() + } else { + return cb(er) + } + }) +} |