heroku-cli-addons
Advanced tools
Comparing version 1.1.7 to 1.1.8
@@ -125,3 +125,3 @@ 'use strict' | ||
args: [{name: 'addon'}, {name: 'plan', optional: true}], | ||
run: cli.command(co.wrap(run)) | ||
run: cli.command({preauth: true}, co.wrap(run)) | ||
} | ||
@@ -128,0 +128,0 @@ |
@@ -5,3 +5,3 @@ 'use strict' | ||
exports.addon = memoize(function (heroku, app, id, headers) { | ||
const addonResolver = function (heroku, app, id, headers) { | ||
headers = headers || {} | ||
@@ -15,4 +15,33 @@ let getAddon = function (id) { | ||
.catch(function (err) { if (err.statusCode === 404) return getAddon(id); else throw err }) | ||
}, (_, app, id) => `${app}-${id}`) | ||
} | ||
/** | ||
* Replacing memoize with our own memoization function that works with promises | ||
* https://github.com/lodash/lodash/blob/da329eb776a15825c04ffea9fa75ae941ea524af/lodash.js#L10534 | ||
*/ | ||
const memoizePromise = function (func, resolver) { | ||
var memoized = function () { | ||
const args = arguments | ||
const key = resolver.apply(this, args) | ||
const cache = memoized.cache | ||
if (cache.has(key)) { | ||
return cache.get(key) | ||
} | ||
const result = func.apply(this, args) | ||
result.then(function () { | ||
memoized.cache = cache.set(key, result) || cache | ||
return arguments | ||
}) | ||
return result | ||
} | ||
memoized.cache = new memoize.Cache() | ||
return memoized | ||
} | ||
exports.addon = memoizePromise(addonResolver, (_, app, id) => `${app}|${id}`) | ||
exports.attachment = function (heroku, app, id, headers) { | ||
@@ -19,0 +48,0 @@ headers = headers || {} |
{ | ||
"name": "heroku-cli-addons", | ||
"description": "`heroku addons:*` commands", | ||
"version": "1.1.7", | ||
"version": "1.1.8", | ||
"author": "Bo Jeanes @bjeanes", | ||
@@ -6,0 +6,0 @@ "bugs": { |
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
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
41690
1037