Skip to content

Commit

Permalink
Merge pull request #36 from bem-site/BEMINFO-1346
Browse files Browse the repository at this point in the history
Left links overriding only for blocks of added or changed library versions
  • Loading branch information
tormozz48 committed Jul 13, 2015
2 parents 3e88e16 + 760730c commit 1548119
Showing 1 changed file with 31 additions and 1 deletion.
32 changes: 31 additions & 1 deletion src/tasks/override-links.js
Original file line number Diff line number Diff line change
Expand Up @@ -328,7 +328,33 @@ module.exports = function (target) {
return vow.resolve(target);
}

var languages = utility.getLanguages();
var languages = utility.getLanguages(),
librariesChanges = target.getChanges().getLibraries(),
changedLibVersions = []
.concat(librariesChanges.getAdded())
.concat(librariesChanges.getModified());

/**
* Decides that given nodeValue is needed for override links
* @param {Object} nodeValue
* @returns {boolean} flag which indicates that it is important to rescan given source
* and override or re-override links in it
*/
function isNeedToOverride(nodeValue) {
var route = nodeValue.route,
conditions,
lib,
version;

conditions = route.conditions;
lib = conditions.lib;
version = conditions.version;

return changedLibVersions.some(function (item) {
return item.lib === lib && item.version === version;
});
}

return vow.all([
levelDb.get().getByKeyRange(target.KEY.NODE_PREFIX, target.KEY.PEOPLE_PREFIX),
collectUrls(target)
Expand All @@ -338,6 +364,10 @@ module.exports = function (target) {
var nodeValue = nodeRecord.value;

if (nodeValue.source && nodeValue.source.data) {
if(!isNeedToOverride(nodeValue)) {
return vow.resolve();
}

return levelDb.get().get(nodeValue.source.data).then(function (blockValue) {
if (!blockValue) {
return vow.resolve();
Expand Down

0 comments on commit 1548119

Please sign in to comment.