Skip to content
This repository has been archived by the owner on Oct 9, 2020. It is now read-only.

Commit

Permalink
ensure virtual conditions are supported
Browse files Browse the repository at this point in the history
  • Loading branch information
guybedford committed Sep 15, 2016
1 parent b2a80c7 commit b56bcc9
Showing 1 changed file with 10 additions and 18 deletions.
28 changes: 10 additions & 18 deletions lib/trace.js
Original file line number Diff line number Diff line change
Expand Up @@ -330,24 +330,6 @@ Trace.prototype.getLoadRecord = function(canonical, traceOpts, parentStack) {
if (condition.indexOf('|') == -1)
condition += '|default';

// if the condition values have been provided via traceOpts.conditions
// then we dont need to work out variations from the file system and can just take what is given
if (traceOpts.conditions[condition]) {
var branches = {};
traceOpts.conditions[condition].forEach(function(c) {
var branchCanonical = canonical.substr(0, interpolationMatch.index) + c + canonical.substr(interpolationMatch[0].length + interpolationMatch.index);
branches[c] = branchCanonical;
});
return {
name: canonical,
fresh: false,
conditional: {
condition: condition,
branches: branches
}
};
}

var metadata = {};
return Promise.resolve(loader.locate({ name: normalized.replace(interpolationRegEx, '*'), metadata: metadata }))
.then(function(address) {
Expand Down Expand Up @@ -378,6 +360,16 @@ Trace.prototype.getLoadRecord = function(canonical, traceOpts, parentStack) {
branches[interpolate] = pathCanonical;
});

// if the condition values have been provided via traceOpts.conditions
// then add these to the glob variations as well
if (traceOpts.conditions[condition])
traceOpts.conditions[condition].forEach(function(c) {
if (branches[c])
return;
var branchCanonical = canonical.substr(0, interpolationMatch.index) + c + canonical.substr(interpolationMatch[0].length + interpolationMatch.index);
branches[c] = branchCanonical;
});

return {
name: canonical,
fresh: false, // we never cache conditional interpolates and always reglob
Expand Down

0 comments on commit b56bcc9

Please sign in to comment.