UNPKG

myst-cli

Version:
50 lines (49 loc) • 2.06 kB
import chalk from 'chalk'; export function createServerLogger(session, ready) { const logger = { debug(data) { var _a; const line = data.trim(); if (!line || line.startsWith('>') || line.startsWith('Watching')) return; if (line.includes('File changed: app/content')) return; // This is shown elsewhere if (line.includes('started at http://')) { const [, ipAndPort] = line.split('http://'); const port = ipAndPort.split(':')[1].replace(/[^0-9]/g, ''); const local = `http://localhost:${port}`; ready(); session.log.info(`\nšŸ”Œ Server started on port ${port}! 🄳 šŸŽ‰\n\n\n\tšŸ‘‰ ${chalk.green(local)} šŸ‘ˆ\n\n`); (_a = session.showUpgradeNotice) === null || _a === void 0 ? void 0 : _a.call(session); return; } session.log.info(line .replace(/šŸ’æ/g, 'šŸš€') .replace(/(GET) /, 'šŸ’Œ $1 ') .replace(/(POST) /, 'šŸ“¦ $1 ')); }, error(data) { const line = data.trim(); if (!line) return; // This is a spurious Remix warning https://github.com/remix-run/remix/issues/2677 if (line.includes('is not listed in your package.json dependencies')) return; if (line.includes('was not found in your node_modules')) return; // This is the punycode deprecation warning if (line.includes('--trace-deprecation') || line.includes('DEP0040')) return; if (line.startsWith('Rebuilding')) { session.log.debug(line); return; } if (line.startsWith('Done in')) { session.log.info(`āš”ļø ${line.replace('Done', 'Compiled')}`); return; } session.log.error(data); }, }; return logger; }