@elasticprojects/abstract-cli
Advanced tools
Comparing version 0.0.4 to 0.0.5
@@ -6,3 +6,4 @@ "use strict"; | ||
}); | ||
exports.UnknownError = exports.ProjectStatusError = exports.ProjectNotFoundError = exports.StoreInitError = undefined; | ||
exports.UnknownError = exports.ProjectStatusError = exports.ProjectNotFoundError = exports.StoreInitError = exports.ParseError = undefined; | ||
exports.run = run; | ||
exports.status = status; | ||
@@ -63,2 +64,4 @@ | ||
class ParseError extends Error {} | ||
exports.ParseError = ParseError; | ||
class StoreInitError extends AbstractCLIError {} | ||
@@ -80,7 +83,19 @@ exports.StoreInitError = StoreInitError; | ||
function processOutput(output) { | ||
return JSON.parse(output.stdout); | ||
try { | ||
return JSON.parse(output.stdout); | ||
} catch (err) { | ||
throw new ParseError(output.stdout); | ||
} | ||
} | ||
function processError(error) { | ||
const output = JSON.parse(error.stderr); | ||
// allow processOutput to throw a parse error without it being caught here; | ||
if (error instanceof ParseError) throw error; | ||
let output; | ||
try { | ||
output = JSON.parse(error.stderr); | ||
} catch (err) { | ||
throw new ParseError(error.stderr); | ||
} | ||
const klass = ERRORS[output.code] ? ERRORS[output.code] : UnknownError; | ||
@@ -87,0 +102,0 @@ throw new klass(output); |
@@ -8,3 +8,3 @@ { | ||
], | ||
"version": "0.0.4", | ||
"version": "0.0.5", | ||
"license": "UNLICENSED", | ||
@@ -15,3 +15,4 @@ "repository": "elasticprojects/deskapi", | ||
"lint": "eslint index.js", | ||
"prepublish": "babel src/ -d lib && flow-copy-source src lib" | ||
"prepublish": "babel src/ -d lib && flow-copy-source src lib", | ||
"test": "jest" | ||
}, | ||
@@ -25,2 +26,3 @@ "devDependencies": { | ||
"flow-copy-source": "^1.2.1", | ||
"jest": "^21.2.1", | ||
"publish": "^0.6.0" | ||
@@ -27,0 +29,0 @@ }, |
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Native code
Supply chain riskContains native code (e.g., compiled binaries or shared libraries). Including native code can obscure malicious behavior.
Found 1 instance in 1 package
13852757
11
133
1
8