presentercoach / apps /web /scripts /sync-pdf-worker.mjs
nathycodes's picture
Deploy Tech Presenter Coach
ec17af3
Raw History Blame Contribute Delete
689 Bytes
import { copyFile, mkdir } from "node:fs/promises";
import { createRequire } from "node:module";
import path from "node:path";
import { fileURLToPath } from "node:url";
const __filename = fileURLToPath(import.meta.url);
const __dirname = path.dirname(__filename);
const appRoot = path.resolve(__dirname, "..");
const require = createRequire(import.meta.url);
const source = require.resolve("pdfjs-dist/legacy/build/pdf.worker.min.mjs", {
paths: [appRoot],
});
const destination = path.resolve(appRoot, "public", "pdf.worker.min.mjs");
await mkdir(path.dirname(destination), { recursive: true });
await copyFile(source, destination);
console.log(`Synced pdf worker to ${destination}`);