From b7a09a6437c5cf0575165b3f223e10cce9aa0e30 Mon Sep 17 00:00:00 2001 From: Guilherme Carvalho <77246+gvc@users.noreply.github.com> Date: Wed, 30 Oct 2024 14:06:04 -0300 Subject: [PATCH] fix: don't move .next directory if it is in the correct place --- packages/cli/src/commands/build.ts | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/packages/cli/src/commands/build.ts b/packages/cli/src/commands/build.ts index c2bb07bf84..d96fe93d4d 100644 --- a/packages/cli/src/commands/build.ts +++ b/packages/cli/src/commands/build.ts @@ -93,7 +93,13 @@ async function copyResources(basePath: string) { if (process.env.BUILD_CONTEXT === 'vercel') { const toDir = process.cwd() - await copyResource(`${tmpDir}/.next`, `${toDir}/.faststore/.next`) + // Because of how copyResource works (delete the target directory if it exists), + // if we're moving something to the same place it is it will break. + const nextOutputDirectory = `${tmpDir}/.next` + const expectedOutputDirectory = `${toDir}/.faststore/.next` + if (nextOutputDirectory !== expectedOutputDirectory) { + await copyResource(nextOutputDirectory, expectedOutputDirectory) + } await copyResource(`${tmpDir}/public`, `${toDir}/public`) } else { await copyResource(`${tmpDir}/.next`, `${userDir}/.next`)