Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
if (e instanceof UnexpectedServerTerminationError) {
console.log(e.stderr);
} else if (e instanceof ServerSpawnFailureError) {
console.log(e.stderr);
}
console.log();
});
console.log(chalk.cyan('ℹ️ Keeping previous server running.'));
}
// if apps wasn't compiled yet, open browser (if user's did not tell otherwise)
if (!doNotOpenBrowser && !isCompiled) {
openBrowser(
url.format({
protocol,
hostname: 'localhost',
port: webpackPort,
}),
);
}
// print nice info :)
printInstructions(urls);
}
// clear last spawn errors
serverManager.clearSpawnErrors();
// set flag that it has been successfully compiled
urls.lanUrlForTerminal ? ` - Network: ${chalk.cyan(urls.lanUrlForTerminal)}` : '',
].join('\n'),
);
console.log();
}
onCompileDone({
port,
isFirstCompile,
stats,
server,
});
if (isFirstCompile) {
isFirstCompile = false;
openBrowser(urls.localUrlForBrowser);
send({
type: DONE,
urls: {
local: urls.localUrlForTerminal,
lan: urls.lanUrlForTerminal,
rawLocal: urls.localUrlForBrowser,
rawLanUrl: urls.rawLanUrl,
},
});
}
});
const run = async (catalogSrcDir: void | string, options: {port: number, https: boolean, host: string}) => {
clearConsole();
console.log(infoMessage('Starting Catalog …'));
const framework = await detectFramework();
const paths = await loadPaths(catalogSrcDir, undefined, framework);
const port = await detect(options.port);
const url = (options.https ? 'https' : 'http') + '://' + options.host + ':' + port + '/';
const webpackConfig = await loadWebpackConfig({paths, dev: true, framework, url, publicPath: '/'});
await setupCatalog(paths);
await runDevServer(webpackConfig, options.host, port, options.https, paths, framework);
openBrowser(url);
};
devServer.listen(CONFIG.WEBPACK_PORT, CONFIG.WEBPACK_HOST, function (err) {
if (err) {
console.log(err);
}
clearConsole();
console.log(chalk.cyan('Starting the development server...'));
openBrowser('http://localhost:8080');
});
devServer.listen(CONFIG.WEBPACK_PORT, CONFIG.WEBPACK_HOST, function(err) {
if (err) {
console.log(err);
}
clearConsole();
console.log(chalk.cyan('Starting the development server...'));
openBrowser('http://localhost:3000');
});
async function tryOpeningDevToolsAsync({ rootPath, exp, options }): Promise {
const devToolsUrl = await DevToolsServer.startAsync(rootPath);
log(`Expo DevTools is running at ${chalk.underline(devToolsUrl)}`);
if (!options.nonInteractive && !exp.isDetached) {
if (await UserSettings.getAsync('openDevToolsAtStartup', true)) {
log(`Opening DevTools in the browser... (press ${chalk.bold`shift-d`} to disable)`);
openBrowser(devToolsUrl);
} else {
log(
`Press ${chalk.bold`d`} to open DevTools now, or ${chalk.bold`shift-d`} to always open it automatically.`
);
}
}
}
export async function openProjectAsync(
projectRoot: string
): Promise<{ success: true; url: string } | { success: false; error: Error }> {
try {
let url = await UrlUtils.constructWebAppUrlAsync(projectRoot);
if (!url) {
throw new Error('Webpack Dev Server is not running');
}
openBrowser(url);
return { success: true, url };
} catch (e) {
Logger.global.error(`Couldn't start project on web: ${e.message}`);
return { success: false, error: e };
}
}
server(host, chosenPort, (error?: Error) => {
if (error) {
handleError(error);
}
logger.info("Starting development server...");
if (MACHINE === "host") {
logger.info("Application will launch automatically.");
openBrowser(baseUrl);
}
});
})