Skip to content

Commit 8a60324

Browse files
authored
fix: windows doesnt like renaming into a directory that already exists (#299)
1 parent f48af5e commit 8a60324

File tree

2 files changed

+4
-4
lines changed

2 files changed

+4
-4
lines changed

src/build/content/static.ts

+2-2
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
import { existsSync } from 'node:fs'
22
import { cp, mkdir, rename, rm } from 'node:fs/promises'
3-
import { join } from 'node:path'
3+
import { basename, join } from 'node:path'
44

55
import glob from 'fast-glob'
66

@@ -61,7 +61,7 @@ export const copyStaticAssets = async (ctx: PluginContext): Promise<void> => {
6161
export const publishStaticDir = async (ctx: PluginContext): Promise<void> => {
6262
try {
6363
await rm(ctx.tempPublishDir, { recursive: true, force: true })
64-
await mkdir(ctx.tempPublishDir, { recursive: true })
64+
await mkdir(basename(ctx.tempPublishDir), { recursive: true })
6565
await rename(ctx.publishDir, ctx.tempPublishDir)
6666
await rename(ctx.staticDir, ctx.publishDir)
6767
} catch (error) {

tests/integration/static.test.ts

+2-2
Original file line numberDiff line numberDiff line change
@@ -61,7 +61,7 @@ test<FixtureTestContext>('requesting a non existing page route that needs to be
6161
)
6262
})
6363

64-
test.skipIf(platform === 'win32')<FixtureTestContext>('linked static resources are placed in correct place in publish directory (no basePath)', async (ctx) => {
64+
test<FixtureTestContext>('linked static resources are placed in correct place in publish directory (no basePath)', async (ctx) => {
6565
await createFixture('simple-next-app', ctx)
6666
const {
6767
constants: { PUBLISH_DIR },
@@ -110,7 +110,7 @@ test.skipIf(platform === 'win32')<FixtureTestContext>('linked static resources a
110110
).toEqual(publishDirAfterBuild)
111111
})
112112

113-
test.skipIf(platform === 'win32')<FixtureTestContext>(
113+
test<FixtureTestContext>(
114114
'linked static resources are placed in correct place in publish directory (with basePath)',
115115
async (ctx) => {
116116
await createFixture('simple-next-app-base-path', ctx)

0 commit comments

Comments
 (0)