Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
35 changes: 35 additions & 0 deletions apps/api/scripts/copy-build-assets.mjs
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
import fs from "node:fs/promises";
import path from "node:path";
import { fileURLToPath } from "node:url";

const __filename = fileURLToPath(import.meta.url);
const __dirname = path.dirname(__filename);
const projectRoot = path.resolve(__dirname, "..");

const assetCopies = [
{
source: path.join(projectRoot, "src", "db", "migrations"),
target: path.join(projectRoot, "dist", "db", "migrations"),
},
];

const copyDirectory = async (source, target) => {
await fs.mkdir(target, { recursive: true });
const entries = await fs.readdir(source, { withFileTypes: true });

for (const entry of entries) {
const sourcePath = path.join(source, entry.name);
const targetPath = path.join(target, entry.name);

if (entry.isDirectory()) {
await copyDirectory(sourcePath, targetPath);
continue;
}

await fs.copyFile(sourcePath, targetPath);
}
};

for (const asset of assetCopies) {
await copyDirectory(asset.source, asset.target);
}
Loading