Skip to content

Commit

Permalink
chore: formatting-only changes for JS/MD files and pkg json
Browse files Browse the repository at this point in the history
  • Loading branch information
jorenbroekema committed Sep 20, 2023
1 parent c5a9592 commit 87d076e
Show file tree
Hide file tree
Showing 2 changed files with 116 additions and 12,052 deletions.
11 changes: 7 additions & 4 deletions lib/common/formatHelpers/createPropertyFormatter.js
Original file line number Diff line number Diff line change
Expand Up @@ -119,13 +119,13 @@ function createPropertyFormatter({
value = prop.original.value;
}

refs.forEach(ref => {
refs.forEach((ref) => {
// value should be a string that contains the resolved reference
// because Style Dictionary resolved this in the resolution step.
// Here we are undoing that by replacing the value with
// the reference's name
if (ref.value && ref.name) {
const replaceFunc = function() {
const replaceFunc = function () {
if (format === 'css') {
if (outputReferenceFallbacks) {
return `var(${prefix}${ref.name}, ${ref.value})`;
Expand All @@ -135,11 +135,14 @@ function createPropertyFormatter({
} else {
return `${prefix}${ref.name}`;
}
}
};
// when original is object value, we replace value by matching ref.value and putting a var instead
// when original is string value, we replace value by matching original.value and putting a var instead
// this is more friendly to transitive transforms that transform the string values
value = value.replace(originalIsString ? new RegExp(`{${ref.path.join('.')}(.value)?}`, 'g') : ref.value, replaceFunc);
value = value.replace(
originalIsString ? new RegExp(`{${ref.path.join('.')}(.value)?}`, 'g') : ref.value,
replaceFunc,
);
}
});
}
Expand Down
Loading

0 comments on commit 87d076e

Please sign in to comment.