Skip to content

Commit

Permalink
fix(core): remove strong-log-transformer (#28094)
Browse files Browse the repository at this point in the history
<!-- Please make sure you have read the submission guidelines before
posting an PR -->
<!--
https://github.com/nrwl/nx/blob/master/CONTRIBUTING.md#-submitting-a-pr
-->

<!-- Please make sure that your commit message follows our format -->
<!-- Example: `fix(nx): must begin with lowercase` -->

<!-- If this is a particularly complex change or feature addition, you
can request a dedicated Nx release for this pull request branch. Mention
someone from the Nx team or the `@nrwl/nx-pipelines-reviewers` and they
will confirm if the PR warrants its own release for testing purposes,
and generate it for you if appropriate. -->

## Current Behavior
<!-- This is the behavior we have today -->

## Expected Behavior
<!-- This is the behavior we should expect with the changes in this PR
-->

## Related Issue(s)
<!-- Please link the issue being fixed so it gets closed when this is
merged. -->

Fixes #26904
  • Loading branch information
xiongemi authored Sep 26, 2024
1 parent cc428c7 commit 7da6f85
Show file tree
Hide file tree
Showing 5 changed files with 23 additions and 12 deletions.
2 changes: 1 addition & 1 deletion e2e/nx-init/src/nx-init-npm-repo.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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();
Expand Down
1 change: 0 additions & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -370,7 +370,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",
Expand Down
1 change: 0 additions & 1 deletion packages/nx/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -61,7 +61,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",
Expand Down
28 changes: 22 additions & 6 deletions packages/nx/src/tasks-runner/forked-process-task-runner.ts
Original file line number Diff line number Diff line change
@@ -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';
Expand Down Expand Up @@ -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);
}
}

Expand Down Expand Up @@ -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) {
Expand All @@ -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();
},
});
}
3 changes: 0 additions & 3 deletions pnpm-lock.yaml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

0 comments on commit 7da6f85

Please sign in to comment.