fix(ngc): propagate errors to main (#11214)

This commit is contained in:
Alex Eagle 2016-09-01 16:54:37 -07:00 committed by Martin Probst
parent 53cf71430f
commit 5e5ae3cde6
2 changed files with 14 additions and 19 deletions

View File

@ -108,23 +108,19 @@ export class CodeGenerator {
return ngModules;
}, <StaticSymbol[]>[]);
const analyzedNgModules = this.compiler.analyzeModules(ngModules);
return Promise
.all(fileMetas.map(
(fileMeta) => this.compiler
.compile(
fileMeta.fileUrl, analyzedNgModules, fileMeta.components,
fileMeta.ngModules)
.then((generatedModules) => {
generatedModules.forEach((generatedModule) => {
const sourceFile = this.program.getSourceFile(fileMeta.fileUrl);
const emitPath =
this.calculateEmitPath(generatedModule.moduleUrl);
this.host.writeFile(
emitPath, PREAMBLE + generatedModule.source, false, () => {},
[sourceFile]);
});
})))
.catch((e) => { console.error(e.stack); });
return Promise.all(fileMetas.map(
(fileMeta) =>
this.compiler
.compile(
fileMeta.fileUrl, analyzedNgModules, fileMeta.components, fileMeta.ngModules)
.then((generatedModules) => {
generatedModules.forEach((generatedModule) => {
const sourceFile = this.program.getSourceFile(fileMeta.fileUrl);
const emitPath = this.calculateEmitPath(generatedModule.moduleUrl);
this.host.writeFile(
emitPath, PREAMBLE + generatedModule.source, false, () => {}, [sourceFile]);
});
})));
}
static create(

View File

@ -133,8 +133,7 @@ export class Extractor {
});
}));
}))
.then(_ => this.messageBundle)
.catch((e) => { console.error(e.stack); });
.then(_ => this.messageBundle);
if (errors.length) {
throw new Error(errors.map(e => e.toString()).join('\n'));