MCPcopy
hub / github.com/electron/forge / getServerURLs

Function getServerURLs

packages/plugin/vite/src/VitePlugin.ts:426–444  ·  view source on GitHub ↗

* Get a string for Vite's printServerUrls function without actually printing it. * Allows us to set `task.output` to that value without having to pass a custom logger into Vite. * @see https://github.com/vitejs/vite/blob/42233d39674be808a6a1a79f1a6e44ed23ba0d61/packages/vite/src/node/logger.ts#L16

(urls: vite.ResolvedServerUrls)

Source from the content-addressed store, hash-verified

424 * @see https://github.com/vitejs/vite/blob/42233d39674be808a6a1a79f1a6e44ed23ba0d61/packages/vite/src/node/logger.ts#L168-L188
425 */
426function getServerURLs(urls: vite.ResolvedServerUrls) {
427 let output = '';
428 const colorUrl = (url: string) =>
429 chalk.cyan(url.replace(/:(\d+)\//, (_, port) => `:${chalk.bold(port)}/`));
430 for (const url of urls.local) {
431 output += ` ${chalk.green('➜')} ${chalk.bold('Local')}: ${colorUrl(url)}`;
432 }
433 for (const url of urls.network) {
434 output += ` \n${chalk.green('➜')} ${chalk.bold('Network')}: ${colorUrl(url)}`;
435 }
436 if (urls.network.length === 0) {
437 output +=
438 chalk.dim(` \n${chalk.green('➜')} ${chalk.bold('Network')}: use `) +
439 chalk.bold('--host') +
440 chalk.dim(' to expose');
441 }
442
443 return output;
444}
445
446export { VitePlugin };

Callers 1

VitePluginClass · 0.85

Calls 1

colorUrlFunction · 0.85

Tested by

no test coverage detected