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

View File

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