1 | /**
|
2 | * @license
|
3 | * Copyright (c) 2017 The Polymer Project Authors. All rights reserved.
|
4 | * This code may only be used under the BSD style license found at
|
5 | * http://polymer.github.io/LICENSE.txt
|
6 | * The complete set of authors may be found at
|
7 | * http://polymer.github.io/AUTHORS.txt
|
8 | * The complete set of contributors may be found at
|
9 | * http://polymer.github.io/CONTRIBUTORS.txt
|
10 | * Code distributed by Google as part of the polymer project is also
|
11 | * subject to an additional IP rights grant found at
|
12 | * http://polymer.github.io/PATENTS.txt
|
13 | */
|
14 |
|
15 | // Be mindful of adding imports here, as this is on the hot path of all
|
16 | // commands.
|
17 |
|
18 | import * as logging from 'plylog';
|
19 | import * as updateNotifier from 'update-notifier';
|
20 | import {PolymerCli} from './polymer-cli';
|
21 |
|
22 | const packageJson = require('../package.json');
|
23 | const logger = logging.getLogger('cli.main');
|
24 |
|
25 | // Update Notifier: Asynchronously check for package updates and, if needed,
|
26 | // notify on the next time the CLI is run.
|
27 | // See https://github.com/yeoman/update-notifier#how for info on how this works.
|
28 | updateNotifier({pkg: packageJson}).notify();
|
29 |
|
30 | (async () => {
|
31 | const args = process.argv.slice(2);
|
32 | const cli = new PolymerCli(args);
|
33 | try {
|
34 | const result = await cli.run();
|
35 | if (result && result.constructor &&
|
36 | result.constructor.name === 'CommandResult') {
|
37 | process.exit(result.exitCode);
|
38 | }
|
39 | } catch (err) {
|
40 | logger.error('cli runtime exception: ' + err);
|
41 | if (err.stack) {
|
42 | logger.error(err.stack);
|
43 | }
|
44 | process.exit(1);
|
45 | }
|
46 | })();
|