From 23f8a25e8e2a424a85dc8b84a9a7dd1afd69a5da Mon Sep 17 00:00:00 2001 From: Joren Broekema Date: Mon, 9 Sep 2024 18:27:30 +0200 Subject: [PATCH] fix: use cp and rmdir for copy_assets action (#1329) --- .changeset/violet-clocks-fetch.md | 5 +++++ lib/common/actions.js | 11 +++++++++-- 2 files changed, 14 insertions(+), 2 deletions(-) create mode 100644 .changeset/violet-clocks-fetch.md diff --git a/.changeset/violet-clocks-fetch.md b/.changeset/violet-clocks-fetch.md new file mode 100644 index 000000000..512a41bea --- /dev/null +++ b/.changeset/violet-clocks-fetch.md @@ -0,0 +1,5 @@ +--- +'style-dictionary': patch +--- + +Use cp and rmdir commands for `copy_assets` do and undo methods, since they affect directories, not files. diff --git a/lib/common/actions.js b/lib/common/actions.js index 8ab495ffb..7aec74247 100644 --- a/lib/common/actions.js +++ b/lib/common/actions.js @@ -78,14 +78,21 @@ export default { // eslint-disable-next-line no-console console.log('Copying assets directory to ' + config.buildPath + 'assets'); } - return vol.promises.copyFile('assets', config.buildPath + 'assets'); + return vol.promises.cp( + 'assets', + config.buildPath + 'assets', + // @ts-expect-error ICpOptions requires other props, this is a mistake in memfs types definition + { + recursive: true, + }, + ); }, undo: async function (_, config, options, vol = fs) { if (config.log?.verbosity !== 'silent') { // eslint-disable-next-line no-console console.log('Removing assets directory from ' + config.buildPath + 'assets'); } - return vol.promises.unlink(config.buildPath + 'assets'); + return vol.promises.rmdir(config.buildPath + 'assets', { recursive: true }); }, }, };