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

Commit

Permalink
allow conditions to directly imply interpolation variations
Browse files Browse the repository at this point in the history
  • Loading branch information
guybedford committed Sep 15, 2016
1 parent 941315e commit e5132e3
Showing 1 changed file with 18 additions and 0 deletions.
18 changes: 18 additions & 0 deletions lib/trace.js
Original file line number Diff line number Diff line change
Expand Up @@ -330,6 +330,24 @@ 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

0 comments on commit e5132e3

Please sign in to comment.