Skip to content

Commit dfc0782

Browse files
committed
fixup! feat(@angular/build): enhance build logs and output location for library builder
1 parent 6936e55 commit dfc0782

2 files changed

Lines changed: 38 additions & 7 deletions

File tree

‎packages/angular/build/src/builders/library/builder.ts‎

Lines changed: 11 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -350,12 +350,16 @@ function logBuildResult(
350350
outputPath?: string,
351351
): void {
352352
const buildTime = Number(process.hrtime.bigint() - startTime) / 10 ** 9;
353-
354-
logger.info(
355-
`Library bundle generation ${success ? 'complete' : 'failed'}. [${buildTime.toFixed(3)} seconds] - ${new Date().toISOString()}`,
356-
);
357-
358-
if (success && outputPath) {
359-
logger.info(`Output location: ${outputPath}\n`);
353+
const message =
354+
`Library bundle generation ${success ? 'complete' : 'failed'}.` +
355+
` [${buildTime.toFixed(3)} seconds] - ${new Date().toISOString()}`;
356+
357+
if (success) {
358+
logger.info(message);
359+
if (outputPath) {
360+
logger.info(`Output location: ${outputPath}\n`);
361+
}
362+
} else {
363+
logger.error(message);
360364
}
361365
}

‎packages/angular/build/src/builders/library/tests/behavior/build_spec.ts‎

Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -162,5 +162,32 @@ describeLibraryBuilder(executeLibraryBuilder, LIBRARY_BUILDER_INFO, (harness) =>
162162
}),
163163
);
164164
});
165+
166+
it('should log failure on build error', async () => {
167+
await harness.writeFile(
168+
'projects/lib/src/public-api.ts',
169+
`export const title: number = 'invalid type';`,
170+
);
171+
172+
harness.useTarget('build', {
173+
...BASE_OPTIONS,
174+
});
175+
176+
const { result, logs } = await harness.executeOnce();
177+
expect(result?.success).toBeFalse();
178+
expect(logs).toContain(
179+
jasmine.objectContaining({
180+
level: 'error',
181+
message: jasmine.stringMatching(
182+
/Library bundle generation failed\. \[\d+\.\d{3} seconds\] - \d{4}-\d{2}-\d{2}T/,
183+
),
184+
}),
185+
);
186+
expect(logs).not.toContain(
187+
jasmine.objectContaining({
188+
message: jasmine.stringMatching(/Output location:/),
189+
}),
190+
);
191+
});
165192
});
166193
});

0 commit comments

Comments
 (0)