Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
if (process.platform === 'darwin') {
try {
// Try our best to reuse existing tab
// on OS X Google Chrome with AppleScript
execSync('ps cax | grep "Google Chrome"');
execSync(
`osascript ${path.join(__dirname, './open-chrome.applescript')} ${url}`,
);
return true;
} catch (err) {
// Ignore errors.
}
}
// Fallback to opn
try {
opn(url);
return true;
} catch (err) {
return false;
}
};
process.exit(1);
});
} else {
server({
root: process.cwd(),
port: argv.port,
run: argv.run,
watch: argv.watch,
}).listen(argv.port);
const url = `http://localhost:${argv.port}`;
console.log(`Quik is serving files at ${chalk.blue(url)}`);
if (argv.browser) {
opn(url, { app: argv.browser });
} else {
opn(url);
}
}
const [, consoleCommand] = input;
await application.server.run(consoleCommand, settings);
return {mode: 'console'};
}
await application.start();
if (settings.open) {
const {host, port} = application.configuration.server;
const address = `http://${host}:${port}`;
const explicit = typeof settings.open === 'string';
const openOptions = explicit ? {app: settings.open} : {};
const browserName = explicit ? settings.open : 'default browser';
application.log.info(`Opening ${browserName} at ${address}`);
opn(address, openOptions)
.catch(error => {
application.log.error(error);
console.log(error.stack);
});
}
return {mode: 'server'};
}
server.listen(options.port, options.host, (err) => {
if (err) {
reject(err);
return;
}
console.log(`Starting webpack dev server at ${options.uri()}`);
open(options.uri());
resolve();
});
});
(stats) => {
if (!browserOpened) {
console.log('opening browser', stats.compilation.compiler.name);
openBrowser(urlToOpenOnStart).then(() => {
browserOpened = true;
});
}
}
);
app.listen(port, function(err) {
if (err) {
console.log(err);
} else {
opn('http://localhost:' + port);
}
});
app.listen(port, (err) => {
if (err) {
console.log(err);
return;
}
if (autoOpenBrowser && process.env.NODE_ENV !== 'testing') {
opn(uri);
}
});
export function startBrowser (url, options) {
if (options && options.start || options.launch) {
const _option = _.omit(options, ['start', 'launch']);
opn(url, options)
}
}
function launchChrome(url: string) {
opn(url, { app: [getChromeAppName()] }, err => {
if (err) {
logger.error('Google Chrome exited with error:', err);
}
});
}
.then(() => opn(url, { app: process.env.BROWSER }))
.catch(() => {})