From b56bcc993ea3675612381e103a250ee0a23a2587 Mon Sep 17 00:00:00 2001 From: guybedford Date: Fri, 16 Sep 2016 00:37:49 +0200 Subject: [PATCH] ensure virtual conditions are supported --- lib/trace.js | 28 ++++++++++------------------ 1 file changed, 10 insertions(+), 18 deletions(-) diff --git a/lib/trace.js b/lib/trace.js index 233d4a2..6116c7a 100644 --- a/lib/trace.js +++ b/lib/trace.js @@ -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) { @@ -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