refactor(dx/server): extract basic build commands to separate file

This commit is contained in:
Elian Doran
2025-09-01 19:36:14 +03:00
parent 978e6b9dde
commit 1e991c0526
2 changed files with 38 additions and 21 deletions

28
scripts/build-utils.ts Normal file
View File

@@ -0,0 +1,28 @@
import { rmSync } from "fs";
import { copySync, emptyDirSync, mkdirpSync } from "fs-extra";
import { join } from "path";
export default class BuildHelper {
private projectDir: string;
private outDir: string;
constructor(projectPath: string) {
this.projectDir = join(__dirname, "..", projectPath);
this.outDir = join(this.projectDir, "dist");
emptyDirSync(this.outDir);
}
copy(projectDirPath: string, outDirPath: string) {
if (outDirPath.endsWith("/")) {
mkdirpSync(join(outDirPath));
}
copySync(join(this.projectDir, projectDirPath), join(this.outDir, outDirPath), { dereference: true });
}
deleteFromOutput(path: string) {
rmSync(join(this.outDir, path), { recursive: true });
}
}