configure-output.js
This file
Path
examples/configure-output.js
25 lines · 730 bytes · JavaScript
Last changed by
Switching to esm-only (#2464)John Geebefore adoptionf4bd470
History of this fileTake it
The walk stopped after 200 commits: lines older than 471ec40 point at it.
Switching to esm-only (#2464)John Geebefore adoptionf4bd470
lines 1–2why, one step back1import { Command } from 'commander';2const program = new Command();Add copyInheritedSettings to README (#1798)John Geebefore adoption471ec40
lines 3–8why, one step back34function errorColor(str) {5 // Add ANSI escape codes to display text in red.6 return `\x1b[31m${str}\x1b[0m`;7}8Reformat code with Prettier (#2180)John Geebefore adoption1bdc749
lines 9–15why, one step back9program.configureOutput({10 // Visibly override write routines as example!11 writeOut: (str) => process.stdout.write(`[OUT] ${str}`),12 writeErr: (str) => process.stdout.write(`[ERR] ${str}`),13 // Output errors in red.14 outputError: (str, write) => write(errorColor(str)),15});Add copyInheritedSettings to README (#1798)John Geebefore adoption471ec40
line 16why, one step back16Reformat code with Prettier (#2180)John Geebefore adoption1bdc749
line 17why, one step back17program.version('1.2.3').option('-c, --compress').command('sub-command');Add copyInheritedSettings to README (#1798)John Geebefore adoption471ec40
lines 18–25why, one step back1819program.parse();2021// Try the following:22// node configure-output.js --version23// node configure-output.js --unknown24// node configure-output.js --help25// node configure-output.js