Skip to content

Commit

Permalink
chore: ensure prefix written on every newline
Browse files Browse the repository at this point in the history
  • Loading branch information
wemeetagain committed Oct 12, 2023
1 parent 8c67bff commit baf06d1
Showing 1 changed file with 12 additions and 2 deletions.
14 changes: 12 additions & 2 deletions src/utils.js
Original file line number Diff line number Diff line change
Expand Up @@ -585,6 +585,16 @@ export const formatCode = (code, errorLines) => {
*/
export function pipeOutput (subprocess, prefix, shouldPrefix) {
prefix = shouldPrefix === false ? '' : kleur.gray(prefix + ': ')
subprocess.stdout?.on('data', (data) => process.stdout.write(`${prefix}${data}`))
subprocess.stderr?.on('data', (data) => process.stderr.write(`${prefix}${data}`))
subprocess.stdout?.on('data', (data) => process.stdout.write(
data.toString('utf8')
.split('\n')
.map((/** @type {string} */ line) => `${prefix}${line}`)
.join('\n')
))
subprocess.stderr?.on('data', (data) => process.stderr.write(
data.toString('utf8')
.split('\n')
.map((/** @type {string} */ line) => `${prefix}${line}`)
.join('\n')
))
}

0 comments on commit baf06d1

Please sign in to comment.