@aziontech/opennextjs-azion
Version:
Azion builder for next apps
21 lines (20 loc) • 892 B
JavaScript
/**
* This code was originally copied and modified from the @opennextjs/cloudflare repository.
* Significant changes have been made to adapt it for use with Azion.
*/
import fs from "node:fs";
import path from "node:path";
import { getOutputWorkerPath } from "../../bundle-server.js";
/**
* Copies
* - the template files present in the azion package to `.open-next/azion-runtime`
* - `worker.js` to `.open-next/`
*/
export function copyPackageCliFiles(packageDistDir, buildOpts) {
console.log("# copyPackageTemplateFiles");
const sourceDir = path.join(packageDistDir, "runtime");
const destinationDir = path.join(buildOpts.outputDir, "azion-runtime");
fs.mkdirSync(destinationDir, { recursive: true });
fs.cpSync(sourceDir, destinationDir, { recursive: true });
fs.copyFileSync(path.join(packageDistDir, "runtime/worker.js"), getOutputWorkerPath(buildOpts));
}