Skip to content

Commit

Permalink
feat(core): do not double prefix output when running nested commands
Browse files Browse the repository at this point in the history
  • Loading branch information
vsavkin committed May 27, 2022
1 parent fea7e39 commit 9d0d0f2
Show file tree
Hide file tree
Showing 5 changed files with 134 additions and 136 deletions.
45 changes: 20 additions & 25 deletions e2e/cli/src/output-style.test.ts
@@ -1,43 +1,38 @@
import {
isNotWindows,
newProject,
readFile,
readJson,
runCLI,
runCLIAsync,
runCommand,
tmpProjPath,
uniq,
updateFile,
updateProjectConfig,
} from '@nrwl/e2e/utils';
import { renameSync } from 'fs';
import { packagesWeCareAbout } from 'nx/src/command-line/report';
import { newProject, runCLI, updateProjectConfig } from '@nrwl/e2e/utils';

describe('Output Style', () => {
beforeEach(() => newProject());

it('should stream output', async () => {
const myapp = uniq('myapp');
it('ttt should stream output', async () => {
const myapp = 'abcdefghijklmon';
runCLI(`generate @nrwl/web:app ${myapp}`);
updateProjectConfig(myapp, (c) => {
c.targets['counter'] = {
executor: '@nrwl/workspace:counter',
c.targets['inner'] = {
executor: '@nrwl/workspace:run-commands',
options: {
to: 2,
command: 'echo inner',
},
};
c.targets['echo'] = {
executor: '@nrwl/workspace:run-commands',
options: {
commands: ['echo 1', 'echo 2', `nx inner ${myapp}`],
parallel: false,
},
};
return c;
});

const withPrefixes = runCLI(
`counter ${myapp} --result=true --output-style=stream`
const withPrefixes = runCLI(`echo ${myapp} --output-style=stream`).split(
'\n'
);
expect(withPrefixes).toContain(`[${myapp}`);
expect(withPrefixes).toContain(`[${myapp}] 1`);
expect(withPrefixes).toContain(`[${myapp}] 2`);
expect(withPrefixes).toContain(`[${myapp}] inner`);

const noPrefixes = runCLI(
`counter ${myapp} --result=true --output-style=stream-without-prefixes`
`echo ${myapp} --output-style=stream-without-prefixes`
);
expect(noPrefixes).not.toContain(`[${myapp}`);
expect(noPrefixes).not.toContain(`[${myapp}]`);
});
});
12 changes: 6 additions & 6 deletions package.json
Expand Up @@ -58,12 +58,12 @@
"@ngrx/schematics": "~13.0.0",
"@ngrx/store": "~13.0.0",
"@ngrx/store-devtools": "~13.0.0",
"@nrwl/eslint-plugin-nx": "14.1.8-beta.5",
"@nrwl/jest": "14.1.8-beta.5",
"@nrwl/next": "14.1.8-beta.5",
"@nrwl/eslint-plugin-nx": "14.1.9-beta.1",
"@nrwl/jest": "14.1.9-beta.1",
"@nrwl/next": "14.1.9-beta.1",
"@nrwl/nx-cloud": "14.0.5",
"@nrwl/react": "14.1.8-beta.5",
"@nrwl/web": "14.1.8-beta.5",
"@nrwl/react": "14.1.9-beta.1",
"@nrwl/web": "14.1.9-beta.1",
"@parcel/watcher": "2.0.4",
"@phenomnomnominal/tsquery": "4.1.1",
"@pmmmwh/react-refresh-webpack-plugin": "^0.5.1",
Expand Down Expand Up @@ -188,7 +188,7 @@
"ng-packagr": "~13.3.0",
"ngrx-store-freeze": "0.2.4",
"node-fetch": "^2.6.7",
"nx": "14.1.8-beta.5",
"nx": "14.1.9-beta.1",
"open": "^8.4.0",
"parse-markdown-links": "^1.0.4",
"parse5": "4.0.0",
Expand Down
1 change: 1 addition & 0 deletions packages/nx/src/tasks-runner/forked-process-task-runner.ts
Expand Up @@ -285,6 +285,7 @@ export class ForkedProcessTaskRunner {
if (!outputPath) {
delete res.NX_TERMINAL_OUTPUT_PATH;
delete res.NX_STREAM_OUTPUT;
delete res.NX_PREFIX_OUTPUT;
}
delete res.NX_SET_CLI;
return res;
Expand Down
3 changes: 2 additions & 1 deletion packages/nx/src/tasks-runner/task-orchestrator.ts
Expand Up @@ -424,7 +424,8 @@ export class TaskOrchestrator {
private pipeOutputCapture(task: Task) {
try {
return (
getExecutorForTask(task, this.workspace).schema.outputCapture === 'pipe'
getExecutorForTask(task, this.workspace).schema.outputCapture ===
'pipe' || process.env.NX_STREAM_OUTPUT === 'true'
);
} catch (e) {
return false;
Expand Down

1 comment on commit 9d0d0f2

@vercel
Copy link

@vercel vercel bot commented on 9d0d0f2 May 27, 2022

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Successfully deployed to the following URLs:

nx-dev – ./

nx.dev
nx-five.vercel.app
nx-dev-nrwl.vercel.app
nx-dev-git-master-nrwl.vercel.app

Please sign in to comment.