From e0e71ae2213e1a0104074ee1e42115d095df3406 Mon Sep 17 00:00:00 2001 From: Larry Davis Date: Thu, 21 Apr 2022 13:37:25 -0700 Subject: [PATCH 1/2] fix: use the token path in whole when no sets are present, fixes #26 --- lib/css-sets-formatter.js | 3 +++ 1 file changed, 3 insertions(+) diff --git a/lib/css-sets-formatter.js b/lib/css-sets-formatter.js index 200f28d..170066b 100644 --- a/lib/css-sets-formatter.js +++ b/lib/css-sets-formatter.js @@ -29,6 +29,9 @@ const formatter = ({ dictionary, platform, file, options }) => { }) ); } + else { + name = name.concat(token.path); + } resultAr.push( ` --${name.join("-")}: ${valueFormatter(token, platform, dictionary)};` ); From 3aac425f3be55d45882934cd08d57335b035c8e6 Mon Sep 17 00:00:00 2001 From: Larry Davis Date: Thu, 21 Apr 2022 13:42:43 -0700 Subject: [PATCH 2/2] test: fix test for no sets, it had sets also, add tests/__output to gitignore so it doesn't get committed --- .gitignore | 3 +++ tests/css-formatter.test.js | 1 + tests/expected/multi-ref.css | 6 +++--- 3 files changed, 7 insertions(+), 3 deletions(-) diff --git a/.gitignore b/.gitignore index 6704566..fc91a00 100644 --- a/.gitignore +++ b/.gitignore @@ -102,3 +102,6 @@ dist # TernJS port file .tern-port + +# Test output +tests/__output diff --git a/tests/css-formatter.test.js b/tests/css-formatter.test.js index c2bcfde..a7d8f96 100644 --- a/tests/css-formatter.test.js +++ b/tests/css-formatter.test.js @@ -91,6 +91,7 @@ test("tokens without sets should still have names", () => { config.platforms.CSS.files[0].filter = (token) => { return !("sets" in token.attributes); }; + delete config.platforms.CSS.files[0].options.sets; const sd = StyleDictionary.extend(config); sd.buildAllPlatforms(); const result = fs.readFileSync( diff --git a/tests/expected/multi-ref.css b/tests/expected/multi-ref.css index f46f92e..41f82e5 100644 --- a/tests/expected/multi-ref.css +++ b/tests/expected/multi-ref.css @@ -1,5 +1,5 @@ :root { - --background-color: var(--color-gray-100); - --light-gray: #EEEEEE; - --dark-gray: #111111; + --component-background-color: var(--color-gray-100); + --static-colors-light-gray: #EEEEEE; + --static-colors-dark-gray: #111111; }