Skip to content

Commit

Permalink
Graceful failure when no gme config entry found. Fixes #257
Browse files Browse the repository at this point in the history
  • Loading branch information
brollb committed Jun 27, 2020
1 parent a2f587a commit b2bb746
Showing 1 changed file with 17 additions and 12 deletions.
29 changes: 17 additions & 12 deletions src/ComponentManager.js
Expand Up @@ -244,28 +244,33 @@ ComponentManager.prototype._getPathFromCliConfig = function(installInfo) {
};

ComponentManager.prototype._getPathFromGME = function(installInfo) {
var pkgProject = installInfo.pkg,
gmeConfigPath = utils.getGMEConfigPath(pkgProject.toLowerCase()),
name = installInfo.name,
componentPath,
otherConfig;

if (exists(gmeConfigPath)) {
otherConfig = require(gmeConfigPath);
componentPath = utils.getPathContaining(otherConfig[this._webgmeName].basePaths.map(
function(p) {
const pkgProject = installInfo.pkg;
const {name} = installInfo;
const gmeConfigPath = utils.getGMEConfigPath(pkgProject.toLowerCase());
const configEntry = this._getGMEConfigEntry(gmeConfigPath);
if (configEntry && configEntry.basePaths) {
const absBasePaths = configEntry.basePaths.map(p => {
if (!path.isAbsolute(p)) {
return path.join(path.dirname(gmeConfigPath), p);
}
return p;
}
), name);
});
const componentPath = utils.getPathContaining(absBasePaths, name);
return componentPath !== null ?
path.join(componentPath, name) : null;
}
return null;
};

ComponentManager.prototype._getGMEConfigEntry = function(gmeConfigPath) {
if (exists(gmeConfigPath)) {
const otherConfig = require(gmeConfigPath);
return otherConfig[this._webgmeName];
}

return null;
};

ComponentManager.prototype._removeFromConfig = function(plugin, type) {
var config = utils.getConfig();
// Remove entry from the config
Expand Down

0 comments on commit b2bb746

Please sign in to comment.