heroku-cli-util
Advanced tools
Comparing version 1.10.4 to 1.11.0
@@ -6,13 +6,34 @@ 'use strict'; | ||
function handleErr(err) { | ||
if (err.body) { | ||
if (err.body.message) { | ||
errors.error(err.body.message); | ||
} else if (err.body.error) { | ||
errors.error(err.body.error); | ||
function handleErr (context) { | ||
return function (err) { | ||
if (err.body) { | ||
// API error | ||
if (err.body.message) { | ||
errors.error(err.body.message); | ||
} else if (err.body.error) { | ||
errors.error(err.body.error); | ||
} | ||
} else { | ||
// Unhandled error | ||
if (err.message) { | ||
errors.error(err.message); | ||
} else { | ||
errors.error(err); | ||
} | ||
if (err.stack) { | ||
var logPath = context.herokuDir + '/error.log'; | ||
var fs = require('fs'); | ||
var log = function (line) { | ||
var d = new Date().toISOString() | ||
.replace(/T/, ' ') | ||
.replace(/-/g, '/') | ||
.replace(/\..+/, ''); | ||
fs.appendFileSync(logPath, d + ' ' + line + '\n'); | ||
}; | ||
log(err.stack); | ||
errors.error(`See ${logPath}` + logPath + ' for more info.'); | ||
} | ||
} | ||
} else { | ||
console.error(err.stack); | ||
} | ||
process.exit(1); | ||
process.exit(1); | ||
}; | ||
} | ||
@@ -29,4 +50,4 @@ | ||
yield fn(context, heroku); | ||
}).catch(handleErr); | ||
}).catch(handleErr(context)); | ||
}; | ||
}; |
@@ -6,7 +6,7 @@ 'use strict'; | ||
function error (msg) { | ||
console.error(chalk.red(` ! ${msg}`)); | ||
console.error(' ' + chalk.bgRed('!') + ' ' + msg); | ||
} | ||
function warn (msg) { | ||
console.error(chalk.yellow(` ! ${msg}`)); | ||
console.error(' ' + chalk.bgYellow('!') + ' ' + msg); | ||
} | ||
@@ -13,0 +13,0 @@ |
{ | ||
"name": "heroku-cli-util", | ||
"version": "1.10.4", | ||
"version": "1.11.0", | ||
"description": "Set of helpful CLI utilities", | ||
@@ -5,0 +5,0 @@ "main": "cli.js", |
@@ -65,4 +65,9 @@ # heroku-cli-util | ||
Used for initializing a plugin command | ||
Used for initializing a plugin command. | ||
It will set the `cwd` to the user's current location, | ||
give you an auth'ed instance of `heroku-client`, | ||
and cleanly handle API exceptions. | ||
It uses `co` so you can `yield` promises. | ||
```js | ||
@@ -69,0 +74,0 @@ let h = require('heroku-cli-util'); |
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
Filesystem access
Supply chain riskAccesses the file system, and could potentially read sensitive data.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
13178
324
108
4