diff --git a/e2e/nx-init/src/nx-init-npm-repo.test.ts b/e2e/nx-init/src/nx-init-npm-repo.test.ts index 36a51f979d039..66f7a22d7db29 100644 --- a/e2e/nx-init/src/nx-init-npm-repo.test.ts +++ b/e2e/nx-init/src/nx-init-npm-repo.test.ts @@ -72,7 +72,7 @@ describe('nx init (NPM repo - legacy)', () => { ); const output = runCommand('npm run compound TEST'); - expect(output).toContain('HELLO\n'); + expect(output).toContain('HELLO'); expect(output).toContain('COMPOUND TEST'); expect(output).not.toContain('HELLO COMPOUND'); cleanupProject(); diff --git a/package.json b/package.json index d81c5de7970d2..c4bdd39420fbf 100644 --- a/package.json +++ b/package.json @@ -366,7 +366,6 @@ "send": "0.17.1", "shadergradient": "^1.2.14", "string-width": "^4.2.3", - "strong-log-transformer": "^2.1.0", "tailwind-merge": "^2.4.0", "tailwindcss": "3.4.4", "three": "^0.166.1", diff --git a/packages/nx/package.json b/packages/nx/package.json index d389ce2022040..af0b312526ba0 100644 --- a/packages/nx/package.json +++ b/packages/nx/package.json @@ -62,7 +62,6 @@ "open": "^8.4.0", "semver": "^7.5.3", "string-width": "^4.2.3", - "strong-log-transformer": "^2.1.0", "tar-stream": "~2.2.0", "tmp": "~0.2.1", "tsconfig-paths": "^4.1.2", diff --git a/packages/nx/src/tasks-runner/forked-process-task-runner.ts b/packages/nx/src/tasks-runner/forked-process-task-runner.ts index b4501b76215e2..a58eab0d46b85 100644 --- a/packages/nx/src/tasks-runner/forked-process-task-runner.ts +++ b/packages/nx/src/tasks-runner/forked-process-task-runner.ts @@ -1,7 +1,6 @@ import { readFileSync, writeFileSync } from 'fs'; import { ChildProcess, fork, Serializable } from 'child_process'; import * as chalk from 'chalk'; -import * as logTransformer from 'strong-log-transformer'; import { DefaultTasksRunnerOptions } from './default-tasks-runner'; import { output } from '../utils/output'; import { getCliPath, getPrintableCommandArgsForTask } from './utils'; @@ -326,15 +325,15 @@ export class ForkedProcessTaskRunner { .pipe( logClearLineToPrefixTransformer(color.bold(prefixText) + ' ') ) - .pipe(logTransformer({ tag: color.bold(prefixText) })) + .pipe(addPrefixTransformer(color.bold(prefixText))) .pipe(process.stdout); p.stderr .pipe(logClearLineToPrefixTransformer(color(prefixText) + ' ')) - .pipe(logTransformer({ tag: color(prefixText) })) + .pipe(addPrefixTransformer(color(prefixText))) .pipe(process.stderr); } else { - p.stdout.pipe(logTransformer()).pipe(process.stdout); - p.stderr.pipe(logTransformer()).pipe(process.stderr); + p.stdout.pipe(addPrefixTransformer()).pipe(process.stdout); + p.stderr.pipe(addPrefixTransformer()).pipe(process.stderr); } } @@ -539,7 +538,7 @@ function getColor(projectName: string) { /** * Prevents terminal escape sequence from clearing line prefix. */ -function logClearLineToPrefixTransformer(prefix) { +function logClearLineToPrefixTransformer(prefix: string) { let prevChunk = null; return new Transform({ transform(chunk, _encoding, callback) { @@ -552,3 +551,20 @@ function logClearLineToPrefixTransformer(prefix) { }, }); } + +function addPrefixTransformer(prefix?: string) { + const newLineSeparator = process.platform.startsWith('win') ? '\r\n' : '\n'; + return new Transform({ + transform(chunk, _encoding, callback) { + const list = chunk.toString().split(/\r\n|[\n\v\f\r\x85\u2028\u2029]/g); + list + .filter(Boolean) + .forEach((m) => + this.push( + prefix ? prefix + ' ' + m + newLineSeparator : m + newLineSeparator + ) + ); + callback(); + }, + }); +} diff --git a/pnpm-lock.yaml b/pnpm-lock.yaml index 7bf4d455e561f..5a8a37d615818 100644 --- a/pnpm-lock.yaml +++ b/pnpm-lock.yaml @@ -147,9 +147,6 @@ importers: string-width: specifier: ^4.2.3 version: 4.2.3 - strong-log-transformer: - specifier: ^2.1.0 - version: 2.1.0 tailwind-merge: specifier: ^2.4.0 version: 2.5.2