1
0
Fork 0
management/front/dkha-web-sz-main/node_modules/webpack-dev-server/lib/utils/runOpen.js

29 lines
793 B
JavaScript
Raw Normal View History

2023-12-18 13:12:25 +08:00
'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 openMessage = 'Unable to open browser';
if (typeof options.open === 'string') {
openOptions = Object.assign({}, openOptions, { app: options.open });
openMessage += `: ${options.open}`;
}
const pageUrl =
options.openPage && isAbsoluteUrl(options.openPage)
? options.openPage
: `${uri}${options.openPage || ''}`;
return open(pageUrl, openOptions).catch(() => {
log.warn(
`${openMessage}. If you are running in a headless environment, please do not use the --open flag`
);
});
}
module.exports = runOpen;