summaryrefslogtreecommitdiff
path: root/scripts/cmd/copy.js
diff options
context:
space:
mode:
Diffstat (limited to 'scripts/cmd/copy.js')
-rw-r--r--scripts/cmd/copy.js11
1 files changed, 11 insertions, 0 deletions
diff --git a/scripts/cmd/copy.js b/scripts/cmd/copy.js
new file mode 100644
index 000000000..0fffae1c3
--- /dev/null
+++ b/scripts/cmd/copy.js
@@ -0,0 +1,11 @@
+import { promises as fs } from 'fs';
+import { resolve, dirname } from 'path';
+import glob from 'tiny-glob';
+
+export default async function copy(pattern, ...args) {
+ const files = await glob(pattern, { filesOnly: true });
+ await Promise.all(files.map(file => {
+ const dest = resolve(file.replace(/^[^/]+/, 'dist'));
+ return fs.mkdir(dirname(dest), { recursive: true }).then(() => fs.copyFile(resolve(file), dest))
+ }));
+}