UNPKG

nx

Version:

The core Nx plugin contains the core functionality of Nx like the project graph, nx commands and task orchestration.

53 lines (52 loc) 1.59 kB
"use strict"; Object.defineProperty(exports, "__esModule", { value: true }); exports.logger = exports.NX_ERROR = exports.NX_PREFIX = void 0; exports.stripIndent = stripIndent; const pc = require("picocolors"); exports.NX_PREFIX = pc.inverse(pc.bold(pc.cyan(' NX '))); exports.NX_ERROR = pc.inverse(pc.bold(pc.red(' ERROR '))); exports.logger = { warn: (s) => console.warn(pc.bold(pc.yellow(s))), error: (s) => { if (typeof s === 'string' && s.startsWith('NX ')) { console.error(`\n${exports.NX_ERROR} ${pc.bold(pc.red(s.slice(3)))}\n`); } else if (s instanceof Error && s.stack) { console.error(pc.bold(pc.red(s.stack))); } else { console.error(pc.bold(pc.red(s))); } }, info: (s) => { if (typeof s === 'string' && s.startsWith('NX ')) { console.info(`\n${exports.NX_PREFIX} ${pc.bold(s.slice(3))}\n`); } else { console.info(s); } }, log: (...s) => { console.log(...s); }, debug: (...s) => { console.debug(...s); }, fatal: (...s) => { console.error(...s); }, verbose: (...s) => { if (process.env.NX_VERBOSE_LOGGING === 'true') { console.log(...s); } }, }; function stripIndent(str) { const match = str.match(/^[ \t]*(?=\S)/gm); if (!match) { return str; } const indent = match.reduce((r, a) => Math.min(r, a.length), Infinity); const regex = new RegExp(`^[ \\t]{${indent}}`, 'gm'); return str.replace(regex, ''); }