Skip to content

Commit

Permalink
Abstracted some package management functionality (#106)
Browse files Browse the repository at this point in the history
  • Loading branch information
andersevenrud committed Apr 11, 2020
1 parent e6ffd58 commit a7eeeef
Showing 1 changed file with 14 additions and 12 deletions.
26 changes: 14 additions & 12 deletions src/packages.js
Original file line number Diff line number Diff line change
Expand Up @@ -358,15 +358,7 @@ export default class Packages {
* @param {PackageInstallationOption} [options]
*/
uninstall(name, options = {}) {
return this._apiRequest('uninstall', {
name,
options: createPackageInstallationOptions(options)
})
.then((body) => {
if (body.reload) {
this.init();
}
});
return this._manageApiRequest('uninstall', options, {name});
}

/**
Expand All @@ -375,10 +367,20 @@ export default class Packages {
* @param {PackageInstallationOption} [options]
*/
install(url, options = {}) {
return this._apiRequest('install', {
url,
return this._manageApiRequest('install', options, {url});
}

/**
* Creates a new API request for package management
* @param {string} endpoint
* @param {object} body
* @param {object} append
* @return {object} JSON
*/
_manageApiRequest(endpoint, options, append) {
return this._apiRequest(endpoint, Object.assign({
options: createPackageInstallationOptions(options)
})
}, append))
.then((body) => {
if (body.reload) {
this.init();
Expand Down

0 comments on commit a7eeeef

Please sign in to comment.