UNPKG

1.13 kBJavaScriptView Raw
1#!/usr/bin/env node
2"use strict";
3Object.defineProperty(exports, "__esModule", { value: true });
4const lib_1 = require("../lib");
5const args_1 = require("./lib/args");
6const main = () => Promise.resolve()
7 // Parse arguments.
8 .then(args_1.parse)
9 // Create action.
10 .then(({ action, format, stats, ignoredPackages, bail }) => lib_1.actions(action, { stats, ignoredPackages }).then((instance) =>
11// Render, report, and bail if configured.
12instance.template.render(format)
13 .then((out) => {
14 // Report.
15 console.log(out); // tslint:disable-line no-console
16 // Don't bother checking if we aren't going to bail.
17 if (!bail) {
18 return Promise.resolve();
19 }
20 // Check and bail if appropriate.
21 return instance.shouldBail().then((shouldBail) => {
22 if (shouldBail) {
23 throw new Error(`Issues found in action: ${action}`);
24 }
25 });
26})))
27 .catch((err) => {
28 // Try to get full stack, then full string if not.
29 console.error(err.stack || err.toString()); // tslint:disable-line no-console
30 process.exit(1);
31});
32if (require.main === module) {
33 main();
34}