Skip to content

Commit

Permalink
chore: only .toString() if dirty
Browse files Browse the repository at this point in the history
  • Loading branch information
tivac committed Aug 7, 2023
1 parent 880b5a2 commit a6dd6c2
Showing 1 changed file with 6 additions and 1 deletion.
7 changes: 6 additions & 1 deletion packages/processor/plugins/values-replace.js
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,7 @@ module.exports = () => ({
const replacer = (prop) =>
(thing) => {
const parsed = value(thing[prop]);
let modified = false;

parsed.walk((node) => {
if(node.type !== "word" || !values[node.value]) {
Expand All @@ -47,9 +48,13 @@ module.exports = () => ({

// Replace any value instances
node.value = current.value;

modified = true;
});

thing[prop] = parsed.toString();
if(modified) {
thing[prop] = parsed.toString();
}
};

return {
Expand Down

0 comments on commit a6dd6c2

Please sign in to comment.