Pete Bacon Darwin d805526659 fix(ngcc): provide a unique exit code for timeouts (#36838)
When ngcc fails due to a timeout waiting for another process
to complete, it was not failing with a unique exit code, so that it
was not possible to know if the process can be restarted; compared to
ngcc failing for some more fatal reason.

Now if ngcc exits because of a timeout, the exit code will be 177.

PR Close #36838
2020-05-01 09:52:09 -07:00

31 lines
892 B
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
*/
import {mainNgcc} from './src/main';
import {parseCommandLineOptions} from './src/command_line_options';
// CLI entry point
if (require.main === module) {
process.title = 'ngcc';
const startTime = Date.now();
const options = parseCommandLineOptions(process.argv.slice(2));
(async () => {
try {
await mainNgcc(options);
if (options.logger) {
const duration = Math.round((Date.now() - startTime) / 1000);
options.logger.debug(`Run ngcc in ${duration}s.`);
}
process.exitCode = 0;
} catch (e) {
console.error(e.stack || e.message);
process.exit(typeof e.code === 'number' ? e.code : 1);
}
})();
}