fix: write logs to stderr to avoid interfering with piped output

Change log() function to use console.error instead of console.log.
This ensures that when stdout is piped (e.g., to 'code -'), only
the prompt file path is sent through the pipe, while progress
messages remain visible on the terminal via stderr.

Usage:
  echo 'content' | yarn --silent docs:create --products X | code -
jts-multifile-plugins-guide
Jason Stirnaman 2025-11-01 10:24:55 -05:00
parent 45a5de02b6
commit e4a659b269
1 changed files with 3 additions and 2 deletions

View File

@ -55,10 +55,11 @@ const colors = {
};
/**
* Print colored output
* Print colored output to stderr (so it doesn't interfere with piped output)
*/
function log(message, color = 'reset') {
console.log(`${colors[color]}${message}${colors.reset}`);
// Write to stderr so logs don't interfere with stdout (prompt path/text)
console.error(`${colors[color]}${message}${colors.reset}`);
}
/**