Files
angular-docs-cn/modules/@angular/compiler-cli/src/main.ts
T

26 lines
771 B
JavaScript
Raw Normal View History

#!/usr/bin/env node
// Must be imported first, because angular2 decorators throws on load.
import 'reflect-metadata';
import * as ts from 'typescript';
import * as tsc from '@angular/tsc-wrapped';
2016-05-01 11:22:39 -07:00
2016-05-24 10:53:48 -07:00
import {CodeGenerator} from './codegen';
2016-05-01 11:22:39 -07:00
2016-05-24 10:53:48 -07:00
function codegen(ngOptions: tsc.AngularCompilerOptions, program: ts.Program, host: ts.CompilerHost) {
return CodeGenerator.create(ngOptions, program, host).codegen();
}
// CLI entry point
if (require.main === module) {
const args = require('minimist')(process.argv.slice(2));
2016-05-24 10:53:48 -07:00
tsc.main(args.p || args.project || '.', args.basePath, codegen)
2016-05-01 11:22:39 -07:00
.then(exitCode => process.exit(exitCode))
.catch(e => {
console.error(e.stack);
console.error("Compilation failed");
process.exit(1);
});
}