2016-05-03 20:31:40 -04:00
|
|
|
#!/usr/bin/env node
|
2016-06-23 12:47:54 -04:00
|
|
|
/**
|
|
|
|
* @license
|
|
|
|
* Copyright Google Inc. All Rights Reserved.
|
|
|
|
*
|
|
|
|
* Use of this source code is governed by an MIT-style license that can be
|
|
|
|
* found in the LICENSE file at https://angular.io/license
|
|
|
|
*/
|
|
|
|
|
2016-04-29 13:35:36 -04:00
|
|
|
|
|
|
|
// Must be imported first, because angular2 decorators throws on load.
|
|
|
|
import 'reflect-metadata';
|
|
|
|
|
|
|
|
import * as ts from 'typescript';
|
2016-05-27 19:22:16 -04:00
|
|
|
import * as tsc from '@angular/tsc-wrapped';
|
2016-05-01 14:22:39 -04:00
|
|
|
|
2016-05-24 13:53:48 -04:00
|
|
|
import {CodeGenerator} from './codegen';
|
2016-05-01 14:22:39 -04:00
|
|
|
|
2016-06-08 19:38:52 -04:00
|
|
|
function codegen(
|
2016-08-12 17:45:36 -04:00
|
|
|
ngOptions: tsc.AngularCompilerOptions, cliOptions: tsc.NgcCliOptions, program: ts.Program,
|
|
|
|
host: ts.CompilerHost) {
|
2016-10-25 19:28:22 -04:00
|
|
|
return CodeGenerator.create(ngOptions, cliOptions, program, host).codegen({
|
|
|
|
transitiveModules: true
|
|
|
|
});
|
2016-04-29 13:35:36 -04:00
|
|
|
}
|
|
|
|
|
|
|
|
// CLI entry point
|
|
|
|
if (require.main === module) {
|
|
|
|
const args = require('minimist')(process.argv.slice(2));
|
2016-08-12 17:45:36 -04:00
|
|
|
const project = args.p || args.project || '.';
|
|
|
|
const cliOptions = new tsc.NgcCliOptions(args);
|
|
|
|
tsc.main(project, cliOptions, codegen).then(exitCode => process.exit(exitCode)).catch(e => {
|
|
|
|
console.error(e.stack);
|
|
|
|
console.error('Compilation failed');
|
|
|
|
process.exit(1);
|
|
|
|
});
|
2016-04-29 13:35:36 -04:00
|
|
|
}
|