Skip to content

Commit

Permalink
Merge pull request #904 from zeitgeist87/order-components
Browse files Browse the repository at this point in the history
Add after-property to allow ordering of plugins
  • Loading branch information
LeaVerou committed Feb 26, 2016
2 parents 8cf72b3 + 224b7a1 commit 9c1a970
Show file tree
Hide file tree
Showing 2 changed files with 17 additions and 6 deletions.
2 changes: 2 additions & 0 deletions components.js
Original file line number Diff line number Diff line change
Expand Up @@ -606,6 +606,7 @@ var components = {
"keep-markup": {
"title": "Keep Markup",
"owner": "Golmote",
"after": "normalize-whitespace",
"noCSS": true
},
"command-line": {
Expand All @@ -616,6 +617,7 @@ var components = {
"normalize-whitespace": {
"title": "Normalize Whitespace",
"owner": "zeitgeist87",
"after": "unescaped-markup",
"noCSS": true
}
}
Expand Down
21 changes: 15 additions & 6 deletions download.js
Original file line number Diff line number Diff line change
Expand Up @@ -117,6 +117,7 @@ for (var category in components) {
noJS: all[id].noJS || all.meta.noJS,
enabled: checked,
require: $u.type(all[id].require) === 'string' ? [all[id].require] : all[id].require,
after: $u.type(all[id].after) === 'string' ? [all[id].after] : all[id].after,
owner: all[id].owner,
files: {
minified: {
Expand Down Expand Up @@ -374,18 +375,21 @@ function delayedGenerateCode(){
timerId = setTimeout(generateCode, 500);
}

function getSortedComponentsByRequirements(components){
var sorted = [];
for (var component in components) {
sorted.push(component);
function getSortedComponents(components, requireName, sorted) {
if (!sorted) {
sorted = [];
for (var component in components) {
sorted.push(component);
}
}

var i = 0;
while (i < sorted.length) {
var id = sorted[i];
var indexOfRequirement = i;
var notNow = false;
for (var requirement in components[id].require) {
indexOfRequirement = sorted.indexOf(components[id].require[requirement]);
for (var requirement in components[id][requireName]) {
indexOfRequirement = sorted.indexOf(components[id][requireName][requirement]);
if (indexOfRequirement > i) {
notNow = true;
break;
Expand All @@ -403,6 +407,11 @@ function getSortedComponentsByRequirements(components){
return sorted;
}

function getSortedComponentsByRequirements(components){
var sorted = getSortedComponents(components, "after");
return getSortedComponents(components, "require", sorted);
}

function generateCode(){
var promises = [];
var redownload = {};
Expand Down

0 comments on commit 9c1a970

Please sign in to comment.