Skip to content

Commit 0b88e4c

Browse files
committed
refactor: simplify buildComponent function by removing copyFolders parameter and export copyFilesToFolder
1 parent 4528c91 commit 0b88e4c

File tree

2 files changed

+12
-12
lines changed

2 files changed

+12
-12
lines changed

_build_scripts/build-component.ts

Lines changed: 2 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@ await init();
66
const encoder = new TextEncoder();
77
const decoder = new TextDecoder();
88

9-
export async function buildComponent(componentName: string, folder: string = "", copyFolders: string[] = []) {
9+
export async function buildComponent(componentName: string, folder: string = "") {
1010
console.log(`Building ${componentName}`);
1111

1212
if (folder.length > 0) {
@@ -15,12 +15,6 @@ export async function buildComponent(componentName: string, folder: string = "",
1515

1616
await build_src(componentName, folder);
1717
await copy_files(componentName, folder);
18-
19-
if (copyFolders.length > 0) {
20-
for (const subFolder of copyFolders) {
21-
await copyFilesToFolder(`components/${componentName}/${folder}${subFolder}`, `dist/components/${componentName}/${folder}`);
22-
}
23-
}
2418
}
2519

2620
async function build_src(componentName: string, folder: string = "") {
@@ -93,7 +87,7 @@ async function copyHTMLFiles(srcFolder: string, distFile: string) {
9387
await Deno.writeTextFile(distFile, result);
9488
}
9589

96-
async function copyFilesToFolder(sourceDir: string, targetDir: string) {
90+
export async function copyFilesToFolder(sourceDir: string, targetDir: string) {
9791
for await (const entry of Deno.readDir(sourceDir)) {
9892
const srcPath = `${sourceDir}/${entry.name}`;
9993
const distPath = `${targetDir}/${entry.name}`;

_build_scripts/build.ts

Lines changed: 10 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,5 @@
11
import { buildSrcFile } from "./build-src.ts";
2-
import { buildComponent } from "./build-component.ts";
3-
import { build } from "https://deno.land/x/[email protected]/mod.d.ts";
2+
import { buildComponent, copyFilesToFolder } from "./build-component.ts";
43

54
async function cleaerDistFolder() {
65
const hasDistFolder = await Deno.stat("dist").catch(() => null);
@@ -16,11 +15,18 @@ async function cleaerDistFolder() {
1615
await cleaerDistFolder();
1716

1817
// Components
18+
19+
await buildComponent("material-icon");
20+
await copyFilesToFolder("components/material-icon/icons", "dist/components/material-icon/icons");
21+
1922
await buildComponent("activity-state");
2023
await buildComponent("app-header");
2124
await buildComponent("dynamic-rows");
2225
await buildComponent("dynamic-columns");
23-
await buildComponent("material-icon", "", ["icons"]);
26+
27+
await buildComponent("material-icon");
28+
await copyFilesToFolder("components/material-icon/icons", "dist/components/material-icon/icons");
29+
2430
await buildComponent("divider-item", "menu");
2531
await buildComponent("menu-container", "menu");
2632
await buildComponent("menu-group", "menu");
@@ -29,7 +35,7 @@ await buildComponent("menu-label", "menu");
2935
await buildComponent("toast-notification");
3036
await buildComponent("tool-bar");
3137
await buildComponent("tree-view");
32-
// await buildComponent("ollama-ui");
38+
await buildComponent("ollama-ui");
3339

3440
// Modules
3541
await buildSrcFile("modules/canvas.js");

0 commit comments

Comments
 (0)