Skip to content

Commit

Permalink
Merge d24feb1 into 7844ed3
Browse files Browse the repository at this point in the history
  • Loading branch information
joeheyming committed Oct 12, 2018
2 parents 7844ed3 + d24feb1 commit 9671705
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 1 deletion.
2 changes: 1 addition & 1 deletion src/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ const varRgx = /^[@$]/;
const followVar = (value, lessVars, dictionary) => {
if (varRgx.test(value)) {
// value is a variable
return followVar(lessVars[value] || dictionary[value.replace(varRgx, '')]);
return followVar(lessVars[value] || dictionary[value.replace(varRgx, '')], lessVars, dictionary);
}
return value;
};
Expand Down
12 changes: 12 additions & 0 deletions test/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -157,3 +157,15 @@ it('should support sass variables with stripPrefix', () => expect(lessVarsToJS(`
'font-stack': 'Helvetica, sans-serif',
'primary-color': '#333'
}));

it('should recursively call followVar', () => expect(lessVarsToJS(`
@klm: @hij;
@abc: '#fff';
@def: @abc;
@hij: @def;
`, { stripPrefix: true, resolveVariables: true })).to.deep.equal({
abc: '#fff',
def: '#fff',
hij: '#fff',
klm: '#fff'
}));

0 comments on commit 9671705

Please sign in to comment.