Skip to content

Commit

Permalink
fix: use cp and rmdir for copy_assets action (#1329)
Browse files Browse the repository at this point in the history
  • Loading branch information
jorenbroekema authored Sep 9, 2024
1 parent ed64bee commit 23f8a25
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 2 deletions.
5 changes: 5 additions & 0 deletions .changeset/violet-clocks-fetch.md
Original file line number Diff line number Diff line change
@@ -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.
11 changes: 9 additions & 2 deletions lib/common/actions.js
Original file line number Diff line number Diff line change
Expand Up @@ -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 });
},
},
};

0 comments on commit 23f8a25

Please sign in to comment.