Skip to content

Commit e42342b

Browse files
committed
Persist plugin management settings during update
1 parent ebc1b8b commit e42342b

2 files changed

Lines changed: 15 additions & 2 deletions

File tree

lib/bowermanager.js

Lines changed: 11 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -301,19 +301,29 @@ BowerManager.prototype.importPackage = function (plugin, packageInfo, options, c
301301

302302
// Add the package to the collection.
303303
// Check if a plugin with this name and version already exists.
304-
db.retrieve(plugin.getPluginType(), { name: package.name, version: package.version }, function (err, results) {
304+
db.retrieve(plugin.getPluginType(), {
305+
name: package.name
306+
}, function (err, results) {
305307
if (err) {
306308
logger.log('error', err);
307309
return callback(err);
308310
}
309311

310312
if (results && results.length !== 0) {
313+
var installedPlugin = results[0];
314+
315+
if (installedPlugin.version === package.version) {
311316
// Don't add a duplicate.
312317
if (options.strict) {
313318
return callback("Can't add " + pluginString + ": verion already exists");
314319
}
315320

316321
return callback(null);
322+
}
323+
324+
var keysToPersist = [ '_isAvailableInEditor', '_isAddedByDefault' ];
325+
326+
keysToPersist.forEach(key => package[key] = installedPlugin[key]);
317327
}
318328

319329
// Add the new plugin.

plugins/content/bower/index.js

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -879,7 +879,10 @@ function addPackage (plugin, packageInfo, options, cb) {
879879
});
880880

881881
// Persist the _isAvailableInEditor flag.
882-
db.update(plugin.type, {_id: newPlugin._id}, {_isAvailableInEditor: oldPlugin._isAvailableInEditor}, function(err, results) {
882+
db.update(plugin.type, {_id: newPlugin._id}, {
883+
_isAvailableInEditor: oldPlugin._isAvailableInEditor,
884+
_isAddedByDefault: oldPlugin._isAddedByDefault
885+
}, function(err, results) {
883886
if (err) {
884887
logger.log('error', err);
885888
return addCb(err);

0 commit comments

Comments
 (0)