Skip to content

Commit 9d2ba06

Browse files
committed
Skip plugin update if no newer compatible release
1 parent 3de21ac commit 9d2ba06

1 file changed

Lines changed: 28 additions & 7 deletions

File tree

lib/bowermanager.js

Lines changed: 28 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -173,20 +173,41 @@ BowerManager.prototype.installLatestCompatibleVersion = function (pluginName, ca
173173
}
174174
var requiredFrameworkVersion;
175175
var index = -1;
176+
var pluginType;
176177
async.doUntil(function iterator(cb) {
177178
bower.commands.info(bowerPackage.url + '#' + latestInfo.versions[++index])
178179
.on('error', cb)
179180
.on('end', function (result) {
180181
requiredFrameworkVersion = result.framework;
182+
pluginType = Object.keys(result).find(key => {
183+
return [ 'component', 'extension', 'menu', 'theme' ].includes(key);
184+
});
181185
cb();
182186
});
183187
}, async function isCompatible() {
184188
return semver.satisfies(installedFrameworkVersion, requiredFrameworkVersion);
185-
}, function(error, version) {
189+
}, error => {
186190
if(error) {
187191
return callback(error);
188192
}
189-
self.installPlugin(pluginName, latestInfo.versions[index], callback);
193+
app.contentmanager.getContentPlugin(pluginType, (error, plugin) => {
194+
if (error) {
195+
return callback(error);
196+
}
197+
app.db.retrieve(plugin.getPluginType(), {
198+
name: pluginName
199+
}, (error, results) => {
200+
if (error) {
201+
return callback(error);
202+
}
203+
var installedPlugin = results[0];
204+
var version = latestInfo.versions[index];
205+
if (installedPlugin && semver.gte(installedPlugin.version, version)) {
206+
return callback('Skipping as no newer compatible version found');
207+
}
208+
self.installPlugin(pluginName, version, callback);
209+
});
210+
});
190211
});
191212
});
192213
});
@@ -285,12 +306,12 @@ BowerManager.prototype.importPackage = function (plugin, packageInfo, options, c
285306
}
286307

287308
if (results && results.length !== 0) {
288-
// Don't add a duplicate.
289-
if (options.strict) {
290-
return callback("Can't add " + pluginString + ": verion already exists");
291-
}
309+
// Don't add a duplicate.
310+
if (options.strict) {
311+
return callback("Can't add " + pluginString + ": verion already exists");
312+
}
292313

293-
return callback(null);
314+
return callback(null);
294315
}
295316

296317
// Add the new plugin.

0 commit comments

Comments
 (0)