Skip to content

Commit 5c1028c

Browse files
committed
Improve the reporting for projects whose build script is an empty string
1 parent b7fee48 commit 5c1028c

File tree

4 files changed

+27
-7
lines changed

4 files changed

+27
-7
lines changed

apps/rush-lib/src/logic/taskRunner/ITask.ts

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,12 @@ export interface ITaskDefinition {
2121
*/
2222
isIncrementalBuildAllowed: boolean;
2323

24+
/**
25+
* Assigned by execute(). True if the build script was an empty string. Operationally an empty string is
26+
* like a shell command that succeeds instantly, but e.g. it would be odd to report build time statistics for it.
27+
*/
28+
hadEmptyScript: boolean;
29+
2430
/**
2531
* Method to be executed for the task.
2632
*/

apps/rush-lib/src/logic/taskRunner/ProjectTask.ts

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -42,6 +42,7 @@ export class ProjectTask implements ITaskDefinition {
4242
}
4343

4444
public isIncrementalBuildAllowed: boolean;
45+
public hadEmptyScript: boolean = false;
4546

4647
private _hasWarningOrError: boolean;
4748
private _rushProject: RushConfigurationProject;
@@ -64,6 +65,9 @@ export class ProjectTask implements ITaskDefinition {
6465
public execute(writer: ITaskWriter): Promise<TaskStatus> {
6566
try {
6667
const taskCommand: string = this._getScriptToRun();
68+
if (!taskCommand) {
69+
this.hadEmptyScript = true;
70+
}
6771
const deps: IPackageDependencies | undefined = this._getPackageDependencies(taskCommand, writer);
6872
return this._executeTask(taskCommand, writer, deps);
6973
} catch (error) {

apps/rush-lib/src/logic/taskRunner/TaskRunner.ts

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -272,8 +272,13 @@ export class TaskRunner {
272272
* Marks a task as being completed, and removes it from the dependencies list of all its dependents
273273
*/
274274
private _markTaskAsSuccess(task: ITask): void {
275-
this._terminal.writeLine(Colors.green(`${this._getCurrentCompletedTaskString()}`
275+
if (task.hadEmptyScript) {
276+
this._terminal.writeLine(Colors.green(`${this._getCurrentCompletedTaskString()}`
277+
+ `[${task.name}] had an empty script`));
278+
} else {
279+
this._terminal.writeLine(Colors.green(`${this._getCurrentCompletedTaskString()}`
276280
+ `[${task.name}] completed successfully in ${task.stopwatch.toString()}`));
281+
}
277282
task.status = TaskStatus.Success;
278283

279284
task.dependents.forEach((dependent: ITask) => {
@@ -417,7 +422,7 @@ export class TaskRunner {
417422
case TaskStatus.SuccessWithWarning:
418423
case TaskStatus.Blocked:
419424
case TaskStatus.Failure:
420-
if (task.stopwatch) {
425+
if (task.stopwatch && !task.hadEmptyScript) {
421426
const time: string = task.stopwatch.toString();
422427
this._terminal.writeLine(headingColor(`${task.name} (${time})`));
423428
} else {

apps/rush-lib/src/logic/taskRunner/test/TaskRunner.test.ts

Lines changed: 10 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,8 @@ function createDummyTask(name: string, action?: () => void): ITaskDefinition {
1414
action();
1515
}
1616
return Promise.resolve(TaskStatus.Success);
17-
}
17+
},
18+
hadEmptyScript: false
1819
};
1920
}
2021

@@ -95,7 +96,8 @@ describe('TaskRunner', () => {
9596
writer.write('Build step 1' + EOL);
9697
writer.writeError('Error: step 1 failed' + EOL);
9798
return Promise.resolve(TaskStatus.Failure);
98-
}
99+
},
100+
hadEmptyScript: false
99101
});
100102
return taskRunner
101103
.execute()
@@ -117,7 +119,8 @@ describe('TaskRunner', () => {
117119
writer.write('Build step 1' + EOL);
118120
writer.write('Error: step 1 failed' + EOL);
119121
return Promise.resolve(TaskStatus.Failure);
120-
}
122+
},
123+
hadEmptyScript: false
121124
});
122125
return taskRunner
123126
.execute()
@@ -139,7 +142,8 @@ describe('TaskRunner', () => {
139142
writer.write(` - unit #${i};${EOL}`);
140143
}
141144
return Promise.resolve(TaskStatus.Failure);
142-
}
145+
},
146+
hadEmptyScript: false
143147
});
144148
return taskRunner
145149
.execute()
@@ -162,7 +166,8 @@ describe('TaskRunner', () => {
162166
writer.writeError(` - error #${i}; ${EOL}`);
163167
}
164168
return Promise.resolve(TaskStatus.Failure);
165-
}
169+
},
170+
hadEmptyScript: false
166171
});
167172
return taskRunner
168173
.execute()

0 commit comments

Comments
 (0)