Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Left links overriding only for blocks of added or changed library versions #36

Merged
merged 2 commits into from
Jul 13, 2015
Merged
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
37 changes: 36 additions & 1 deletion src/tasks/override-links.js
Original file line number Diff line number Diff line change
Expand Up @@ -328,7 +328,38 @@ module.exports = function (target) {
return vow.resolve(target);
}

var languages = utility.getLanguages();
var languages = utility.getLanguages(),
changedLibVersions = []
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

changedLibVersions = [].concat(target.getChanges().getLibraries().getAdded(), target.getChanges().getLibraries().getModified())

или здесь ради красоты 2 раза concat?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

да, для красоты

.concat(target.getChanges().getLibraries().getAdded())
.concat(target.getChanges().getLibraries().getModified());
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

а target.getChanges().getLibraries() мы можем унести в переменную?


function isNeedToOverride(nodeValue) {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Какого-нибудь бы сюда jsdoc

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

неважно

var route = nodeValue.route,
conditions,
lib,
version;

if(!route) {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Это когда такое может случится?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

так безопаснее

return false;
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

здесь нужен явный false или можно просто if(!route) return;
и ниже там аналогичные случаи

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

явное лучше чем неявное

}

conditions = route.conditions;
if(!conditions) {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

а это?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

и так тоже

return false;
}

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

if(!lib || !version) {
return false;
}

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 +369,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