Sha256: 07722b22286c8eac57a7937e3c57126999f28d21dcf233bca30f1695b18a4ac6
Contents?: true
Size: 1.07 KB
Versions: 15
Compression:
Stored size: 1.07 KB
Contents
'use strict'; const open = require('opn'); const isAbsoluteUrl = require('is-absolute-url'); function runOpen(uri, options, log) { // https://github.com/webpack/webpack-dev-server/issues/1990 let openOptions = { wait: false }; let openOptionValue = ''; if (typeof options.open === 'string') { openOptions = Object.assign({}, openOptions, { app: options.open }); openOptionValue = `: "${options.open}"`; } else if (typeof options.open === 'object') { openOptions = options.open; openOptionValue = `: "${JSON.stringify(options.open)}"`; } const pages = typeof options.openPage === 'string' ? [options.openPage] : options.openPage || ['']; return Promise.all( pages.map((page) => { const pageUrl = page && isAbsoluteUrl(page) ? page : `${uri}${page}`; return open(pageUrl, openOptions).catch(() => { log.warn( `Unable to open "${pageUrl}" in browser${openOptionValue}. If you are running in a headless environment, please do not use the --open flag` ); }); }) ); } module.exports = runOpen;
Version data entries
15 entries across 14 versions & 4 rubygems