Skip to content

Commit 343a10c

Browse files
committed
fix: correctly handle the temp folder
And use it (move) as the build folder
1 parent 4ee55df commit 343a10c

File tree

1 file changed

+5
-15
lines changed

1 file changed

+5
-15
lines changed

packages/open-next/src/build.ts

Lines changed: 5 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -47,7 +47,9 @@ export async function build(
4747
showWindowsWarning();
4848

4949
// Load open-next.config.ts
50-
const tempConfigDir = fs.mkdtempSync("open-next");
50+
const tempConfigDir = fs.mkdtempSync(
51+
path.join(os.tmpdir(), ".open-next-temp"),
52+
);
5153
let configPath = compileOpenNextConfigNode(
5254
tempConfigDir,
5355
openNextConfigPath,
@@ -174,20 +176,8 @@ function initOutputDir(options: BuildOptions) {
174176
fs.rmSync(options.outputDir, { recursive: true, force: true });
175177
const { buildDir } = options;
176178
fs.mkdirSync(buildDir, { recursive: true });
177-
178-
fs.copyFileSync(
179-
path.join(options.tempConfigDir, "open-next.config.mjs"),
180-
path.join(buildDir, "open-next.config.mjs"),
181-
);
182-
183-
try {
184-
fs.copyFileSync(
185-
path.join(options.tempConfigDir, "open-next.config.edge.mjs"),
186-
path.join(buildDir, "open-next.config.edge.mjs"),
187-
);
188-
} catch {
189-
// The edge config does not always exist.
190-
}
179+
fs.renameSync(options.tempConfigDir, buildDir);
180+
process.exit(0);
191181
}
192182

193183
async function createWarmerBundle(options: BuildOptions) {

0 commit comments

Comments
 (0)