UNPKG

monex

Version:

Execute one or multiple scripts, interactively or in daemon mode, and restart them whenever they crash or a watched file changes.

19 lines (18 loc) 591 B
/* IMPORT */ import process from 'node:process'; import { color } from 'specialist'; /* MAIN */ const Logger = { /* API */ log: (data, prefixName, prefixColor) => { if (!prefixName) return void process.stdout.write(data); const prefix = prefixColor ? color.bold(color[prefixColor](prefixName)) : color.bold(prefixName); const lines = data.toString().replace(/^\r?\n|\r?\n$/, '').split(/\r?\n|\r/g); lines.forEach(line => { process.stdout.write(`[${prefix}] ${line}\n`); }); } }; /* EXPORT */ export default Logger;