2018-07-16 03:49:56 -04:00
|
|
|
#!/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
|
|
|
|
*/
|
2019-03-20 09:47:58 -04:00
|
|
|
import * as path from 'canonical-path';
|
|
|
|
import * as yargs from 'yargs';
|
2018-07-16 03:49:56 -04:00
|
|
|
|
|
|
|
import {mainNgcc} from './src/main';
|
2019-03-20 09:47:58 -04:00
|
|
|
import {EntryPointFormat} from './src/packages/entry_point';
|
2018-07-16 03:49:56 -04:00
|
|
|
|
|
|
|
// CLI entry point
|
|
|
|
if (require.main === module) {
|
|
|
|
const args = process.argv.slice(2);
|
2019-03-20 09:47:58 -04:00
|
|
|
const options =
|
|
|
|
yargs
|
|
|
|
.option('s', {
|
|
|
|
alias: 'source',
|
|
|
|
describe: 'A path to the root folder to compile.',
|
|
|
|
default: './node_modules'
|
|
|
|
})
|
|
|
|
.option('f', {
|
|
|
|
alias: 'formats',
|
|
|
|
array: true,
|
|
|
|
describe: 'An array of formats to compile.',
|
|
|
|
default: ['fesm2015', 'esm2015', 'fesm5', 'esm5']
|
|
|
|
})
|
|
|
|
.option('t', {
|
|
|
|
alias: 'target',
|
|
|
|
describe: 'A path to a root folder where the compiled files will be written.',
|
|
|
|
defaultDescription: 'The `source` folder.'
|
|
|
|
})
|
|
|
|
.help()
|
|
|
|
.parse(args);
|
|
|
|
|
|
|
|
const baseSourcePath: string = path.resolve(options['s']);
|
|
|
|
const formats: EntryPointFormat[] = options['f'];
|
|
|
|
const baseTargetPath: string = options['t'];
|
|
|
|
try {
|
|
|
|
mainNgcc({baseSourcePath, formats, baseTargetPath});
|
|
|
|
process.exitCode = 0;
|
|
|
|
} catch (e) {
|
|
|
|
console.error(e.stack || e.message);
|
|
|
|
process.exitCode = 1;
|
|
|
|
}
|
2018-07-16 03:49:56 -04:00
|
|
|
}
|