mirror of
https://github.com/angular/angular-cli.git
synced 2025-05-18 03:23:57 +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();
|
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) {
|
if (!configExists) {
|
||||||
throw new Error(tags.oneLine`
|
throw new Error(tags.oneLine`
|
||||||
Error: Expected to find an ngsw-config.json configuration
|
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.
|
in your angular.json configuration file.
|
||||||
`);
|
`);
|
||||||
}
|
}
|
||||||
|
@ -261,7 +261,7 @@ export function buildWebpackBrowser(
|
|||||||
})
|
})
|
||||||
.pipe(
|
.pipe(
|
||||||
map(() => ({ success: true })),
|
map(() => ({ success: true })),
|
||||||
catchError(() => of({ success: false })),
|
catchError(error => of({ success: false, error: mapErrorToMessage(error) })),
|
||||||
);
|
);
|
||||||
} else {
|
} else {
|
||||||
return of({ success });
|
return of({ success });
|
||||||
@ -276,7 +276,10 @@ export function buildWebpackBrowser(
|
|||||||
resolve(root, normalize(options.outputPath)),
|
resolve(root, normalize(options.outputPath)),
|
||||||
options.baseHref || '/',
|
options.baseHref || '/',
|
||||||
options.ngswConfigPath,
|
options.ngswConfigPath,
|
||||||
).then(() => ({ success: true }), () => ({ success: false })));
|
).then(
|
||||||
|
() => ({ success: true }),
|
||||||
|
error => ({ success: false, error: mapErrorToMessage(error) }),
|
||||||
|
));
|
||||||
} else {
|
} else {
|
||||||
return of(buildEvent);
|
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);
|
export default createBuilder<json.JsonObject & BrowserBuilderSchema>(buildWebpackBrowser);
|
||||||
|
Loading…
x
Reference in New Issue
Block a user