22 lines
626 B
JavaScript
22 lines
626 B
JavaScript
'use strict';
|
|
|
|
const open = require('opn');
|
|
|
|
function runOpen(uri, options, log) {
|
|
// https://github.com/webpack/webpack-dev-server/issues/1990
|
|
let openOptions = { wait: false };
|
|
let openMessage = 'Unable to open browser';
|
|
|
|
if (typeof options.open === 'string') {
|
|
openOptions = Object.assign({}, openOptions, { app: options.open });
|
|
openMessage += `: ${options.open}`;
|
|
}
|
|
|
|
return open(`${uri}${options.openPage || ''}`, openOptions).catch(() => {
|
|
log.warn(
|
|
`${openMessage}. If you are running in a headless environment, please do not use the --open flag`
|
|
);
|
|
});
|
|
}
|
|
|
|
module.exports = runOpen;
|