UNPKG

7.86 kBJavaScriptView Raw
1'use strict';
2
3Object.defineProperty(exports, "__esModule", {
4 value: true
5});
6
7var _regenerator = require('babel-runtime/regenerator');
8
9var _regenerator2 = _interopRequireDefault(_regenerator);
10
11var _asyncToGenerator2 = require('babel-runtime/helpers/asyncToGenerator');
12
13var _asyncToGenerator3 = _interopRequireDefault(_asyncToGenerator2);
14
15var _getPrototypeOf = require('babel-runtime/core-js/object/get-prototype-of');
16
17var _getPrototypeOf2 = _interopRequireDefault(_getPrototypeOf);
18
19var _classCallCheck2 = require('babel-runtime/helpers/classCallCheck');
20
21var _classCallCheck3 = _interopRequireDefault(_classCallCheck2);
22
23var _createClass2 = require('babel-runtime/helpers/createClass');
24
25var _createClass3 = _interopRequireDefault(_createClass2);
26
27var _possibleConstructorReturn2 = require('babel-runtime/helpers/possibleConstructorReturn');
28
29var _possibleConstructorReturn3 = _interopRequireDefault(_possibleConstructorReturn2);
30
31var _inherits2 = require('babel-runtime/helpers/inherits');
32
33var _inherits3 = _interopRequireDefault(_inherits2);
34
35var _cliEngineCommand = require('cli-engine-command');
36
37var _cliEngineCommand2 = _interopRequireDefault(_cliEngineCommand);
38
39var _plugins = require('./plugins');
40
41var _plugins2 = _interopRequireDefault(_plugins);
42
43var _updater = require('./updater');
44
45var _updater2 = _interopRequireDefault(_updater);
46
47var _not_found = require('./not_found');
48
49var _not_found2 = _interopRequireDefault(_not_found);
50
51function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
52
53if (process.env.HEROKU_TIME_REQUIRE) require('time-require');
54
55var handleEPIPE = function handleEPIPE(err) {
56 if (err.code !== 'EPIPE') throw err;
57};
58
59var Main = function (_Base) {
60 (0, _inherits3.default)(Main, _Base);
61
62 function Main() {
63 (0, _classCallCheck3.default)(this, Main);
64 return (0, _possibleConstructorReturn3.default)(this, (Main.__proto__ || (0, _getPrototypeOf2.default)(Main)).apply(this, arguments));
65 }
66
67 (0, _createClass3.default)(Main, [{
68 key: 'run',
69 value: function () {
70 var _ref = (0, _asyncToGenerator3.default)(_regenerator2.default.mark(function _callee() {
71 var _this2 = this;
72
73 var updater, plugins, Command;
74 return _regenerator2.default.wrap(function _callee$(_context) {
75 while (1) {
76 switch (_context.prev = _context.next) {
77 case 0:
78 process.on('exit', function () {
79 return _this2.showCursor();
80 });
81 process.on('SIGINT', function (err) {
82 return _this2.error(err);
83 });
84 process.on('uncaughtException', function (err) {
85 return _this2.error(err);
86 });
87 process.on('unhandledRejection', function (err) {
88 return _this2.error(err);
89 });
90 process.stdout.on('error', handleEPIPE);
91 process.stderr.on('error', handleEPIPE);
92
93 updater = new _updater2.default(this.config);
94 plugins = new _plugins2.default(this.config);
95 _context.next = 10;
96 return updater.autoupdate();
97
98 case 10:
99 Command = plugins.findCommand(this.config.argv[1] || this.config.defaultCommand);
100
101 if (Command) {
102 _context.next = 13;
103 break;
104 }
105
106 return _context.abrupt('return', new _not_found2.default(this.config).run());
107
108 case 13:
109 this.command = new Command(this.config);
110 _context.prev = 14;
111 _context.next = 17;
112 return this.command._run();
113
114 case 17:
115 _context.next = 22;
116 break;
117
118 case 19:
119 _context.prev = 19;
120 _context.t0 = _context['catch'](14);
121 this.command.error(_context.t0);
122
123 case 22:
124 this.exit(0);
125
126 case 23:
127 case 'end':
128 return _context.stop();
129 }
130 }
131 }, _callee, this, [[14, 19]]);
132 }));
133
134 function run() {
135 return _ref.apply(this, arguments);
136 }
137
138 return run;
139 }()
140 }]);
141 return Main;
142}(_cliEngineCommand2.default);
143
144exports.default = Main;
145//# sourceMappingURL=data:application/json;charset=utf-8;base64,eyJ2ZXJzaW9uIjozLCJzb3VyY2VzIjpbIi4uL3NyYy9jbGkuanMiXSwibmFtZXMiOlsicHJvY2VzcyIsImVudiIsIkhFUk9LVV9USU1FX1JFUVVJUkUiLCJyZXF1aXJlIiwiaGFuZGxlRVBJUEUiLCJlcnIiLCJjb2RlIiwiTWFpbiIsIm9uIiwic2hvd0N1cnNvciIsImVycm9yIiwic3Rkb3V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