@@ -20,8 +20,8 @@ export class WebContainerFiles {
20
20
const cache = new FileMapCache ( logger , server , { contentDir, templatesDir } ) ;
21
21
22
22
this . _watcher = watch ( [
23
- ` ${ contentDir } / **/${ FILES_FOLDER_NAME } /**/*`,
24
- ` ${ contentDir } / **/${ SOLUTION_FOLDER_NAME } /**/*`,
23
+ path . join ( contentDir , ` **/${ FILES_FOLDER_NAME } /**/*`) ,
24
+ path . join ( contentDir , ` **/${ SOLUTION_FOLDER_NAME } /**/*`) ,
25
25
templatesDir ,
26
26
] ) ;
27
27
@@ -57,12 +57,18 @@ export class WebContainerFiles {
57
57
const { contentDir, templatesDir } = this . _folders ( projectRoot ) ;
58
58
59
59
const folders = await glob (
60
- [ `${ contentDir } /**/${ FILES_FOLDER_NAME } ` , `${ contentDir } /**/${ SOLUTION_FOLDER_NAME } ` , `${ templatesDir } /*` ] ,
60
+ [
61
+ `${ glob . convertPathToPattern ( contentDir ) } /**/${ FILES_FOLDER_NAME } ` ,
62
+ `${ glob . convertPathToPattern ( contentDir ) } /**/${ SOLUTION_FOLDER_NAME } ` ,
63
+ `${ glob . convertPathToPattern ( templatesDir ) } /*` ,
64
+ ] ,
61
65
{ onlyDirectories : true } ,
62
66
) ;
63
67
64
68
await Promise . all (
65
69
folders . map ( async ( folder ) => {
70
+ folder = path . normalize ( folder ) ;
71
+
66
72
const fileRef = getFilesRef ( folder , { contentDir, templatesDir } ) ;
67
73
const dest = fileURLToPath ( new URL ( fileRef , dir ) ) ;
68
74
@@ -198,7 +204,7 @@ class FileMapCache {
198
204
}
199
205
200
206
async function createFileMap ( dir : string ) {
201
- const filePaths = await glob ( `${ dir } /**/*` , {
207
+ const filePaths = await glob ( `${ glob . convertPathToPattern ( dir ) } /**/*` , {
202
208
onlyFiles : true ,
203
209
} ) ;
204
210
@@ -261,5 +267,5 @@ function getFilesRef(pathToFolder: string, { contentDir, templatesDir }: Content
261
267
pathToFolder = 'template' + pathToFolder . slice ( templatesDir . length ) ;
262
268
}
263
269
264
- return encodeURIComponent ( pathToFolder . replaceAll ( '/' , '-' ) . replaceAll ( '_' , '' ) ) + '.json' ;
270
+ return encodeURIComponent ( pathToFolder . replaceAll ( / [ \/ \\ ] + / g , '-' ) . replaceAll ( '_' , '' ) ) + '.json' ;
265
271
}
0 commit comments