38 lines
1.1 KiB
JavaScript
38 lines
1.1 KiB
JavaScript
#!/usr/bin/env node
|
|
/**
|
|
* @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
|
|
*/
|
|
|
|
|
|
// 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';
|
|
|
|
import {CodeGenerator} from './codegen';
|
|
|
|
function codegen(
|
|
ngOptions: tsc.AngularCompilerOptions, cliOptions: tsc.NgcCliOptions, program: ts.Program,
|
|
host: ts.CompilerHost) {
|
|
return CodeGenerator.create(ngOptions, cliOptions, program, host).codegen({
|
|
transitiveModules: true
|
|
});
|
|
}
|
|
|
|
// CLI entry point
|
|
if (require.main === module) {
|
|
const args = require('minimist')(process.argv.slice(2));
|
|
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);
|
|
});
|
|
}
|