glow
Advanced tools
Comparing version 1.2.1 to 1.2.2
@@ -123,4 +123,6 @@ 'use strict'; | ||
if (status.errors.length !== 0) { | ||
if (status.errors && status.errors.length !== 0) { | ||
process.exit(1); | ||
} else if (status.exit) { | ||
process.exit(status.exit.code); | ||
} | ||
@@ -127,0 +129,0 @@ |
@@ -47,5 +47,16 @@ 'use strict'; | ||
function startupError(messageKey) { | ||
for (var _len = arguments.length, args = Array(_len > 1 ? _len - 1 : 0), _key = 1; _key < _len; _key++) { | ||
args[_key - 1] = arguments[_key]; | ||
} | ||
var message = _Lang.Lang.get.apply(_Lang.Lang, [messageKey].concat(args)); | ||
console.error(_chalk2.default.red.bold(message)); | ||
process.exit(1); | ||
return new Error(message); | ||
} | ||
exports.default = function () { | ||
var _ref = (0, _asyncToGenerator3.default)( /*#__PURE__*/_regenerator2.default.mark(function _callee(opts) { | ||
var cwd, start, flowConfigPath, flowRootDir, flowConfig, message, env, runner; | ||
var cwd, start, flowConfigPath, flowRootDir, flowConfig, env, runner; | ||
return _regenerator2.default.wrap(function _callee$(_context) { | ||
@@ -70,21 +81,26 @@ while (1) { | ||
flowConfigPath = _context.sent; | ||
if (flowConfigPath) { | ||
_context.next = 8; | ||
break; | ||
} | ||
throw startupError('noFlowConfig'); | ||
case 8: | ||
flowRootDir = flow.getFlowRootDir(flowConfigPath); | ||
_context.next = 9; | ||
_context.next = 11; | ||
return flow.getFlowConfig(flowRootDir); | ||
case 9: | ||
case 11: | ||
flowConfig = _context.sent; | ||
if (flowConfig) { | ||
_context.next = 15; | ||
_context.next = 14; | ||
break; | ||
} | ||
message = _Lang.Lang.get('noFlowBinary', flow.getPossibleFlowBinPaths(flowRootDir).join(', ')); | ||
throw startupError('noFlowBinary', flow.getPossibleFlowBinPaths(flowRootDir).join(', ')); | ||
console.error(_chalk2.default.red.bold(message)); | ||
process.exit(1); | ||
throw new Error(message); | ||
case 15: | ||
case 14: | ||
env = new _Env.Env((0, _extends3.default)({}, opts, { | ||
@@ -102,9 +118,9 @@ flowConfigPath, | ||
runner = new _Runner.Runner({ env }); | ||
_context.next = 20; | ||
_context.next = 19; | ||
return runner.start(); | ||
case 20: | ||
case 19: | ||
return _context.abrupt('return', runner.status); | ||
case 21: | ||
case 20: | ||
case 'end': | ||
@@ -111,0 +127,0 @@ return _context.stop(); |
@@ -42,3 +42,4 @@ 'use strict'; | ||
foundErrorsWithFilters: '%s (Filters match %d)', | ||
noFlowBinary: "Couldn't find any flow binaries in %s" | ||
noFlowBinary: "Couldn't find any flow binaries in %s", | ||
noFlowConfig: "Couldn't find a .flowconfig file" | ||
} | ||
@@ -45,0 +46,0 @@ }; |
@@ -200,3 +200,3 @@ 'use strict'; | ||
var _ref4 = (0, _asyncToGenerator3.default)( /*#__PURE__*/_regenerator2.default.mark(function _callee4() { | ||
var errors, results, _iterator, _isArray, _i, _ref5, error; | ||
var results, errors, _iterator, _isArray, _i, _ref5, error, exit; | ||
@@ -220,9 +220,15 @@ return _regenerator2.default.wrap(function _callee4$(_context4) { | ||
this.status = _context4.sent; | ||
results = []; | ||
if (!this.status.errors) { | ||
_context4.next = 31; | ||
break; | ||
} | ||
errors = this.status.errors; | ||
results = []; | ||
_iterator = errors, _isArray = Array.isArray(_iterator), _i = 0, _iterator = _isArray ? _iterator : (0, _getIterator3.default)(_iterator); | ||
case 8: | ||
case 9: | ||
if (!_isArray) { | ||
_context4.next = 14; | ||
_context4.next = 15; | ||
break; | ||
@@ -232,34 +238,34 @@ } | ||
if (!(_i >= _iterator.length)) { | ||
_context4.next = 11; | ||
_context4.next = 12; | ||
break; | ||
} | ||
return _context4.abrupt('break', 28); | ||
return _context4.abrupt('break', 29); | ||
case 11: | ||
case 12: | ||
_ref5 = _iterator[_i++]; | ||
_context4.next = 18; | ||
_context4.next = 19; | ||
break; | ||
case 14: | ||
case 15: | ||
_i = _iterator.next(); | ||
if (!_i.done) { | ||
_context4.next = 17; | ||
_context4.next = 18; | ||
break; | ||
} | ||
return _context4.abrupt('break', 28); | ||
return _context4.abrupt('break', 29); | ||
case 17: | ||
case 18: | ||
_ref5 = _i.value; | ||
case 18: | ||
case 19: | ||
error = _ref5; | ||
_context4.t0 = results; | ||
_context4.t1 = error; | ||
_context4.next = 23; | ||
_context4.next = 24; | ||
return this.env.printer.printError(error); | ||
case 23: | ||
case 24: | ||
_context4.t2 = _context4.sent; | ||
@@ -273,12 +279,24 @@ _context4.t3 = { | ||
case 26: | ||
_context4.next = 8; | ||
case 27: | ||
_context4.next = 9; | ||
break; | ||
case 28: | ||
case 29: | ||
_context4.next = 32; | ||
break; | ||
case 31: | ||
if (this.status.exit) { | ||
exit = this.status.exit; | ||
results.push({ | ||
message: exit.msg | ||
}); | ||
} | ||
case 32: | ||
this._currentResults = results; | ||
this.render(); | ||
case 30: | ||
case 34: | ||
case 'end': | ||
@@ -324,2 +342,5 @@ return _context4.stop(); | ||
filteredResults = results.filter(function (result) { | ||
if (!result.error) { | ||
return true; | ||
} | ||
return result.error.message.find(function (messagePart) { | ||
@@ -326,0 +347,0 @@ if (messagePart.loc && messagePart.loc.source) { |
@@ -105,5 +105,7 @@ 'use strict'; | ||
if (status.errors.length !== 0) { | ||
if (status.errors && status.errors.length !== 0) { | ||
process.exit(1); | ||
} else if (status.exit) { | ||
process.exit(status.exit.code); | ||
} | ||
}; |
@@ -39,2 +39,9 @@ 'use strict'; | ||
function startupError(messageKey, ...args) { | ||
const message = _Lang.Lang.get(messageKey, ...args); | ||
console.error(_chalk2.default.red.bold(message)); | ||
process.exit(1); | ||
return new Error(message); | ||
} | ||
exports.default = async function glow(opts) { | ||
@@ -51,2 +58,7 @@ let cwd = opts.cwd; | ||
let flowConfigPath = await flow.getFlowConfigPath(cwd); | ||
if (!flowConfigPath) { | ||
throw startupError('noFlowConfig'); | ||
} | ||
let flowRootDir = flow.getFlowRootDir(flowConfigPath); | ||
@@ -56,6 +68,3 @@ let flowConfig = await flow.getFlowConfig(flowRootDir); | ||
if (!flowConfig) { | ||
const message = _Lang.Lang.get('noFlowBinary', flow.getPossibleFlowBinPaths(flowRootDir).join(', ')); | ||
console.error(_chalk2.default.red.bold(message)); | ||
process.exit(1); | ||
throw new Error(message); | ||
throw startupError('noFlowBinary', flow.getPossibleFlowBinPaths(flowRootDir).join(', ')); | ||
} | ||
@@ -62,0 +71,0 @@ |
@@ -35,3 +35,4 @@ 'use strict'; | ||
foundErrorsWithFilters: '%s (Filters match %d)', | ||
noFlowBinary: "Couldn't find any flow binaries in %s" | ||
noFlowBinary: "Couldn't find any flow binaries in %s", | ||
noFlowConfig: "Couldn't find a .flowconfig file" | ||
} | ||
@@ -38,0 +39,0 @@ }; |
@@ -97,9 +97,15 @@ 'use strict'; | ||
this.status = await flow.status(this.env); | ||
let errors = this.status.errors; | ||
let results = []; | ||
for (let error of errors) { | ||
if (this.status.errors) { | ||
let errors = this.status.errors; | ||
for (let error of errors) { | ||
results.push({ | ||
error, | ||
message: await this.env.printer.printError(error) | ||
}); | ||
} | ||
} else if (this.status.exit) { | ||
let exit = this.status.exit; | ||
results.push({ | ||
error, | ||
message: await this.env.printer.printError(error) | ||
message: exit.msg | ||
}); | ||
@@ -138,2 +144,5 @@ } | ||
filteredResults = results.filter(result => { | ||
if (!result.error) { | ||
return true; | ||
} | ||
return result.error.message.find(messagePart => { | ||
@@ -140,0 +149,0 @@ if (messagePart.loc && messagePart.loc.source) { |
{ | ||
"name": "glow", | ||
"version": "1.2.1", | ||
"version": "1.2.2", | ||
"description": "Make your Flow errors GLOW", | ||
@@ -5,0 +5,0 @@ "main": "index.js", |
95318
2486