46 lines
1.2 KiB
TypeScript
46 lines
1.2 KiB
TypeScript
import { copyFile, mkdir, readdir } from 'node:fs/promises';
|
|
import path from 'node:path';
|
|
|
|
interface RuntimeAssetCopy {
|
|
source: string;
|
|
target: string;
|
|
}
|
|
|
|
const runtimeAssetCopies: readonly RuntimeAssetCopy[] = [
|
|
{
|
|
source: 'src/db/migrations/package.json',
|
|
target: 'dist/src/db/migrations/package.json',
|
|
},
|
|
];
|
|
|
|
async function copyRuntimeAsset(copy: RuntimeAssetCopy): Promise<void> {
|
|
await mkdir(path.dirname(copy.target), { recursive: true });
|
|
await copyFile(copy.source, copy.target);
|
|
}
|
|
|
|
async function copyMigrationFiles(): Promise<void> {
|
|
const sourceDirectory = 'src/db/migrations';
|
|
const targetDirectory = 'dist/src/db/migrations';
|
|
const entries = await readdir(sourceDirectory, { withFileTypes: true });
|
|
|
|
await mkdir(targetDirectory, { recursive: true });
|
|
|
|
await Promise.all(
|
|
entries
|
|
.filter((entry) => entry.isFile() && entry.name.endsWith('.js'))
|
|
.map((entry) =>
|
|
copyFile(
|
|
path.join(sourceDirectory, entry.name),
|
|
path.join(targetDirectory, entry.name),
|
|
),
|
|
),
|
|
);
|
|
}
|
|
|
|
async function main(): Promise<void> {
|
|
await Promise.all(runtimeAssetCopies.map((copy) => copyRuntimeAsset(copy)));
|
|
await copyMigrationFiles();
|
|
}
|
|
|
|
void main();
|