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

Commit b56bcc9

Browse files
committed
ensure virtual conditions are supported
1 parent b2a80c7 commit b56bcc9

File tree

1 file changed

+10
-18
lines changed

1 file changed

+10
-18
lines changed

lib/trace.js

Lines changed: 10 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -330,24 +330,6 @@ Trace.prototype.getLoadRecord = function(canonical, traceOpts, parentStack) {
330330
if (condition.indexOf('|') == -1)
331331
condition += '|default';
332332

333-
// if the condition values have been provided via traceOpts.conditions
334-
// then we dont need to work out variations from the file system and can just take what is given
335-
if (traceOpts.conditions[condition]) {
336-
var branches = {};
337-
traceOpts.conditions[condition].forEach(function(c) {
338-
var branchCanonical = canonical.substr(0, interpolationMatch.index) + c + canonical.substr(interpolationMatch[0].length + interpolationMatch.index);
339-
branches[c] = branchCanonical;
340-
});
341-
return {
342-
name: canonical,
343-
fresh: false,
344-
conditional: {
345-
condition: condition,
346-
branches: branches
347-
}
348-
};
349-
}
350-
351333
var metadata = {};
352334
return Promise.resolve(loader.locate({ name: normalized.replace(interpolationRegEx, '*'), metadata: metadata }))
353335
.then(function(address) {
@@ -378,6 +360,16 @@ Trace.prototype.getLoadRecord = function(canonical, traceOpts, parentStack) {
378360
branches[interpolate] = pathCanonical;
379361
});
380362

363+
// if the condition values have been provided via traceOpts.conditions
364+
// then add these to the glob variations as well
365+
if (traceOpts.conditions[condition])
366+
traceOpts.conditions[condition].forEach(function(c) {
367+
if (branches[c])
368+
return;
369+
var branchCanonical = canonical.substr(0, interpolationMatch.index) + c + canonical.substr(interpolationMatch[0].length + interpolationMatch.index);
370+
branches[c] = branchCanonical;
371+
});
372+
381373
return {
382374
name: canonical,
383375
fresh: false, // we never cache conditional interpolates and always reglob

0 commit comments

Comments
 (0)