import { spawnSync, SpawnSyncOptions } from "child_process";

console.log("Running Post build ...");

try {
    const spawnSyncOptions: SpawnSyncOptions = {
        stdio: "inherit",
        encoding: "utf-8",
        cwd: process.cwd(),
        env: {
            ...process.env,
            NODE_ENV: "production",
        },
    };

    const generateSitemap = spawnSync(
        "bunx",
        ["next-sitemap"],
        spawnSyncOptions
    );

    console.log("Post Build Success! Starting Server ...");
} catch (error) {
    console.log("Post Build Error =>", error);
}
