Skip to content

Commit 5d05cfa

Browse files
committed
refactor: export copyFilesToFolder function and ensure target directory is created if it doesn't exist
1 parent 007cc27 commit 5d05cfa

File tree

2 files changed

+8
-2
lines changed

2 files changed

+8
-2
lines changed

_build_scripts/build-component.ts

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -93,11 +93,16 @@ async function copyHTMLFiles(srcFolder: string, distFile: string) {
9393
await Deno.writeTextFile(distFile, result);
9494
}
9595

96-
async function copyFilesToFolder(sourceDir: string, targetDir: string) {
96+
export async function copyFilesToFolder(sourceDir: string, targetDir: string) {
97+
// create targetDir if it does not exist
98+
if (!(await Deno.stat(targetDir).catch(() => null))) {
99+
await Deno.mkdir(targetDir, { recursive: true});
100+
};
101+
97102
for await (const entry of Deno.readDir(sourceDir)) {
98103
const srcPath = `${sourceDir}/${entry.name}`;
99104
const distPath = `${targetDir}/${entry.name}`;
100105

101-
await copy(srcPath, distPath, { overwrite: true });
106+
await Deno.copyFile(srcPath, distPath);
102107
}
103108
}

_build_scripts/build.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -53,6 +53,7 @@ await buildSrcFile("modules/system.js");
5353
await buildSrcFile("modules/tween.js");
5454
await buildSrcFile("modules/view-loader.js");
5555
await buildSrcFile("modules/virtualization.js");
56+
await buildSrcFile("modules/form.js");
5657

5758
// System Files
5859
await buildSrcFile("system/assert.js");

0 commit comments

Comments
 (0)