From 77ae35fcccbdfd331b226debc14663b7fc244ccb Mon Sep 17 00:00:00 2001 From: Joren Broekema Date: Tue, 26 Mar 2024 17:02:06 +0100 Subject: [PATCH] fix: absolute paths in Node env (#1134) --- .changeset/tricky-snakes-appear.md | 5 +++++ lib/utils/combineJSON.js | 7 +++++-- 2 files changed, 10 insertions(+), 2 deletions(-) create mode 100644 .changeset/tricky-snakes-appear.md diff --git a/.changeset/tricky-snakes-appear.md b/.changeset/tricky-snakes-appear.md new file mode 100644 index 000000000..eb87e69a6 --- /dev/null +++ b/.changeset/tricky-snakes-appear.md @@ -0,0 +1,5 @@ +--- +'style-dictionary': patch +--- + +Fix scenario of passing absolute paths in Node env, do not remove leading slash in absolute paths. diff --git a/lib/utils/combineJSON.js b/lib/utils/combineJSON.js index 0924e7e45..89d5597d4 100644 --- a/lib/utils/combineJSON.js +++ b/lib/utils/combineJSON.js @@ -72,8 +72,11 @@ export default async function combineJSON( files = files.concat(new_files); } - // adjust for browser env glob results have leading slash - files = files.map((f) => f.replace(/^\//, '')); + if (typeof window === 'object') { + // adjust for browser env glob results have leading slash + // make sure we dont remove these in Node, that would break absolute paths!! + files = files.map((f) => f.replace(/^\//, '')); + } for (let i = 0; i < files.length; i++) { const filePath = files[i];