fix(core): normalize command to avoid nx run nx run (#8678)

This commit is contained in:
Victor Savkin 2022-01-24 14:18:14 -05:00 committed by GitHub
parent e167fd5992
commit acffba7fa9
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
5 changed files with 13 additions and 12 deletions

View File

@ -40,7 +40,7 @@ export class ForkedProcessTaskRunner {
); );
} else { } else {
const args = getCommandArgsForTask(Object.values(taskGraph.tasks)[0]); const args = getCommandArgsForTask(Object.values(taskGraph.tasks)[0]);
output.logCommand(`${args.filter((a) => a !== 'run').join(' ')}`); output.logCommand(args.join(' '));
output.addNewline(); output.addNewline();
} }
@ -98,7 +98,7 @@ export class ForkedProcessTaskRunner {
try { try {
const args = getCommandArgsForTask(task); const args = getCommandArgsForTask(task);
if (forwardOutput) { if (forwardOutput) {
output.logCommand(`${args.filter((a) => a !== 'run').join(' ')}`); output.logCommand(args.join(' '));
output.addNewline(); output.addNewline();
} }
const p = fork(this.cliPath, args, { const p = fork(this.cliPath, args, {
@ -163,7 +163,7 @@ export class ForkedProcessTaskRunner {
try { try {
const args = getCommandArgsForTask(task); const args = getCommandArgsForTask(task);
if (forwardOutput) { if (forwardOutput) {
output.logCommand(`${args.filter((a) => a !== 'run').join(' ')}`); output.logCommand(args.join(' '));
output.addNewline(); output.addNewline();
} }
const p = fork(this.cliPath, args, { const p = fork(this.cliPath, args, {

View File

@ -16,10 +16,7 @@ export class EmptyTerminalOutputLifeCycle implements LifeCycle {
cacheStatus === 'skipped' cacheStatus === 'skipped'
) { ) {
const args = getCommandArgsForTask(task); const args = getCommandArgsForTask(task);
output.logCommand( output.logCommand(args.join(' '), cacheStatus);
`${args.filter((a) => a !== 'run').join(' ')}`,
cacheStatus
);
output.addNewline(); output.addNewline();
process.stdout.write(terminalOutput); process.stdout.write(terminalOutput);
} }

View File

@ -147,10 +147,7 @@ export class StaticRunManyTerminalOutputLifeCycle implements LifeCycle {
terminalOutput: string terminalOutput: string
) { ) {
const args = getCommandArgsForTask(task); const args = getCommandArgsForTask(task);
output.logCommand( output.logCommand(args.join(' '), cacheStatus);
`${args.filter((a) => a !== 'run').join(' ')}`,
cacheStatus
);
output.addNewline(); output.addNewline();
process.stdout.write(terminalOutput); process.stdout.write(terminalOutput);
} }

View File

@ -118,7 +118,7 @@ export class StaticRunOneTerminalOutputLifeCycle implements LifeCycle {
task.target.project === this.initiatingProject task.target.project === this.initiatingProject
) { ) {
const args = getCommandArgsForTask(task); const args = getCommandArgsForTask(task);
output.logCommand(`${args.filter((a) => a !== 'run').join(' ')}`, status); output.logCommand(args.join(' '), status);
output.addNewline(); output.addNewline();
process.stdout.write(terminalOutput); process.stdout.write(terminalOutput);
} }

View File

@ -207,6 +207,13 @@ class CLIOutput {
} }
logCommand(message: string, taskStatus?: TaskStatus) { logCommand(message: string, taskStatus?: TaskStatus) {
// normalize the message
if (message.startsWith('nx run ')) {
message = message.substring('nx run '.length);
} else if (message.startsWith('run ')) {
message = message.substring('run '.length);
}
this.addNewline(); this.addNewline();
let commandOutput = `${chalk.dim('> nx run')} ${message}`; let commandOutput = `${chalk.dim('> nx run')} ${message}`;
if (taskStatus === 'local-cache') { if (taskStatus === 'local-cache') {