1
1
import { Buffer } from 'node:buffer'
2
2
import { join } from 'node:path'
3
- import { platform } from 'node:process'
4
3
5
4
import type { NetlifyPluginOptions } from '@netlify/build'
6
5
import glob from 'fast-glob'
@@ -30,7 +29,15 @@ const createFsFixtureWithBasePath = (
30
29
)
31
30
}
32
31
33
- describe . skipIf ( platform === 'win32' ) ( 'Regular Repository layout' , ( ) => {
32
+ async function readDirRecursive ( dir : string ) {
33
+ const posixPaths = await glob ( '**/*' , { cwd : dir , dot : true , absolute : true } )
34
+ // glob always returns unix-style paths, even on Windows!
35
+ // To compare them more easily in our tests running on Windows, we convert them to the platform-specific paths.
36
+ const paths = posixPaths . map ( ( posixPath ) => join ( posixPath ) )
37
+ return paths
38
+ }
39
+
40
+ describe ( 'Regular Repository layout' , ( ) => {
34
41
beforeEach < Context > ( ( ctx ) => {
35
42
ctx . publishDir = '.next'
36
43
ctx . pluginContext = new PluginContext ( {
@@ -64,7 +71,7 @@ describe.skipIf(platform === 'win32')('Regular Repository layout', () => {
64
71
)
65
72
66
73
await copyStaticAssets ( pluginContext )
67
- expect ( await glob ( '**/*' , { cwd, dot : true , absolute : true } ) ) . toEqual (
74
+ expect ( await readDirRecursive ( cwd ) ) . toEqual (
68
75
expect . arrayContaining ( [
69
76
join ( cwd , '.next/static/test.js' ) ,
70
77
join ( cwd , '.next/static/sub-dir/test2.js' ) ,
@@ -88,7 +95,7 @@ describe.skipIf(platform === 'win32')('Regular Repository layout', () => {
88
95
)
89
96
90
97
await copyStaticAssets ( pluginContext )
91
- expect ( await glob ( '**/*' , { cwd, dot : true , absolute : true } ) ) . toEqual (
98
+ expect ( await readDirRecursive ( cwd ) ) . toEqual (
92
99
expect . arrayContaining ( [
93
100
join ( cwd , '.next/static/test.js' ) ,
94
101
join ( cwd , '.next/static/sub-dir/test2.js' ) ,
@@ -111,7 +118,7 @@ describe.skipIf(platform === 'win32')('Regular Repository layout', () => {
111
118
)
112
119
113
120
await copyStaticAssets ( pluginContext )
114
- expect ( await glob ( '**/*' , { cwd, dot : true , absolute : true } ) ) . toEqual (
121
+ expect ( await readDirRecursive ( cwd ) ) . toEqual (
115
122
expect . arrayContaining ( [
116
123
join ( cwd , 'public/another-asset.json' ) ,
117
124
join ( cwd , 'public/fake-image.svg' ) ,
@@ -135,7 +142,7 @@ describe.skipIf(platform === 'win32')('Regular Repository layout', () => {
135
142
)
136
143
137
144
await copyStaticAssets ( pluginContext )
138
- expect ( await glob ( '**/*' , { cwd, dot : true , absolute : true } ) ) . toEqual (
145
+ expect ( await readDirRecursive ( cwd ) ) . toEqual (
139
146
expect . arrayContaining ( [
140
147
join ( cwd , 'public/another-asset.json' ) ,
141
148
join ( cwd , 'public/fake-image.svg' ) ,
@@ -186,7 +193,7 @@ describe.skipIf(platform === 'win32')('Regular Repository layout', () => {
186
193
} )
187
194
} )
188
195
189
- describe . skipIf ( platform === 'win32' ) ( 'Mono Repository' , ( ) => {
196
+ describe ( 'Mono Repository' , ( ) => {
190
197
beforeEach < Context > ( ( ctx ) => {
191
198
ctx . publishDir = 'apps/app-1/.next'
192
199
ctx . pluginContext = new PluginContext ( {
@@ -211,7 +218,7 @@ describe.skipIf(platform === 'win32')('Mono Repository', () => {
211
218
)
212
219
213
220
await copyStaticAssets ( pluginContext )
214
- expect ( await glob ( '**/*' , { cwd, dot : true , absolute : true } ) ) . toEqual (
221
+ expect ( await readDirRecursive ( cwd ) ) . toEqual (
215
222
expect . arrayContaining ( [
216
223
join ( cwd , 'apps/app-1/.next/static/test.js' ) ,
217
224
join ( cwd , 'apps/app-1/.next/static/sub-dir/test2.js' ) ,
@@ -235,7 +242,7 @@ describe.skipIf(platform === 'win32')('Mono Repository', () => {
235
242
)
236
243
237
244
await copyStaticAssets ( pluginContext )
238
- expect ( await glob ( '**/*' , { cwd, dot : true , absolute : true } ) ) . toEqual (
245
+ expect ( await readDirRecursive ( cwd ) ) . toEqual (
239
246
expect . arrayContaining ( [
240
247
join ( cwd , 'apps/app-1/.next/static/test.js' ) ,
241
248
join ( cwd , 'apps/app-1/.next/static/sub-dir/test2.js' ) ,
@@ -258,7 +265,7 @@ describe.skipIf(platform === 'win32')('Mono Repository', () => {
258
265
)
259
266
260
267
await copyStaticAssets ( pluginContext )
261
- expect ( await glob ( '**/*' , { cwd, dot : true , absolute : true } ) ) . toEqual (
268
+ expect ( await readDirRecursive ( cwd ) ) . toEqual (
262
269
expect . arrayContaining ( [
263
270
join ( cwd , 'apps/app-1/public/another-asset.json' ) ,
264
271
join ( cwd , 'apps/app-1/public/fake-image.svg' ) ,
@@ -282,7 +289,7 @@ describe.skipIf(platform === 'win32')('Mono Repository', () => {
282
289
)
283
290
284
291
await copyStaticAssets ( pluginContext )
285
- expect ( await glob ( '**/*' , { cwd, dot : true , absolute : true } ) ) . toEqual (
292
+ expect ( await readDirRecursive ( cwd ) ) . toEqual (
286
293
expect . arrayContaining ( [
287
294
join ( cwd , 'apps/app-1/public/another-asset.json' ) ,
288
295
join ( cwd , 'apps/app-1/public/fake-image.svg' ) ,
0 commit comments