mirror of
https://github.com/angular/angular-cli.git
synced 2025-05-17 11:03:53 +08:00
fix(@angular-devkit/build-angular): browser builder should not swollow error messages
Closes #14813
This commit is contained in:
parent
3cd0931eb7
commit
c7135fae35
@ -270,10 +270,14 @@ export abstract class ArchitectCommand<
|
||||
},
|
||||
);
|
||||
|
||||
const result = await run.output.toPromise();
|
||||
const { error, success } = await run.output.toPromise();
|
||||
await run.stop();
|
||||
|
||||
return result.success ? 0 : 1;
|
||||
if (error) {
|
||||
this.logger.error(error);
|
||||
}
|
||||
|
||||
return success ? 0 : 1;
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -102,7 +102,7 @@ export async function augmentAppWithServiceWorker(
|
||||
if (!configExists) {
|
||||
throw new Error(tags.oneLine`
|
||||
Error: Expected to find an ngsw-config.json configuration
|
||||
file in the ${appRoot} folder. Either provide one or disable Service Worker
|
||||
file in the ${getSystemPath(appRoot)} folder. Either provide one or disable Service Worker
|
||||
in your angular.json configuration file.
|
||||
`);
|
||||
}
|
||||
|
@ -261,7 +261,7 @@ export function buildWebpackBrowser(
|
||||
})
|
||||
.pipe(
|
||||
map(() => ({ success: true })),
|
||||
catchError(() => of({ success: false })),
|
||||
catchError(error => of({ success: false, error: mapErrorToMessage(error) })),
|
||||
);
|
||||
} else {
|
||||
return of({ success });
|
||||
@ -276,7 +276,10 @@ export function buildWebpackBrowser(
|
||||
resolve(root, normalize(options.outputPath)),
|
||||
options.baseHref || '/',
|
||||
options.ngswConfigPath,
|
||||
).then(() => ({ success: true }), () => ({ success: false })));
|
||||
).then(
|
||||
() => ({ success: true }),
|
||||
error => ({ success: false, error: mapErrorToMessage(error) }),
|
||||
));
|
||||
} else {
|
||||
return of(buildEvent);
|
||||
}
|
||||
@ -291,4 +294,16 @@ export function buildWebpackBrowser(
|
||||
);
|
||||
}
|
||||
|
||||
function mapErrorToMessage(error: unknown): string | undefined {
|
||||
if (error instanceof Error) {
|
||||
return error.message;
|
||||
}
|
||||
|
||||
if (typeof error === 'string') {
|
||||
return error;
|
||||
}
|
||||
|
||||
return undefined;
|
||||
}
|
||||
|
||||
export default createBuilder<json.JsonObject & BrowserBuilderSchema>(buildWebpackBrowser);
|
||||
|
Loading…
x
Reference in New Issue
Block a user