@@ -234,7 +234,7 @@ export async function bundlePlayWrightProject (
234234 outputFile,
235235 browsers : pwConfigParsed . getBrowsers ( ) ,
236236 playwrightVersion,
237- relativePlaywrightConfigPath : path . relative ( dir , filePath ) ,
237+ relativePlaywrightConfigPath : path . relative ( Session . basePath ! , filePath ) ,
238238 cacheHash,
239239 } )
240240 } )
@@ -283,29 +283,45 @@ export async function loadPlaywrightProjectFiles (
283283 dir : string , pwConfigParsed : PlaywrightConfig , include : string [ ] , archive : Archiver ,
284284 lockFile : string ,
285285) {
286- const ignoredFiles = [ '**/node_modules/**' , '.git/**' ]
287286 const parser = new Parser ( {
288287 workspace : Session . workspace ,
289288 } )
290289 const { files, errors } = await parser . getFilesAndDependencies ( pwConfigParsed )
291- const mode = 0o755 // Default mode for files in the archive
292290 if ( errors . length ) {
293291 throw new Error ( `Error loading playwright project files: ${ errors . map ( ( e : string ) => e ) . join ( ', ' ) } ` )
294292 }
293+ const root = Session . basePath !
294+ const prefix = path . relative ( root , dir )
295+ const fileOptions = {
296+ mode : 0o755 , // Default mode for files in the archive
297+ }
295298 for ( const file of files ) {
296- const relativePath = path . relative ( dir , file )
297- archive . file ( file , { name : relativePath , mode } )
299+ archive . file ( file , {
300+ ...fileOptions ,
301+ name : path . relative ( root , file ) ,
302+ } )
298303 }
299304 const lockFileDirName = path . dirname ( lockFile )
300- archive . file ( lockFile , { name : path . basename ( lockFile ) , mode } )
301- archive . file ( path . join ( lockFileDirName , 'package.json' ) , { name : 'package.json' , mode } )
302- // handle workspaces
303- archive . glob ( '**/package.json' , { cwd : path . join ( dir , '/' ) , ignore : ignoredFiles } , { mode } )
305+ const packageJsonFile = path . join ( lockFileDirName , 'package.json' )
306+ archive . file ( lockFile , {
307+ ...fileOptions ,
308+ name : path . relative ( root , lockFile ) ,
309+ } )
310+ archive . file ( packageJsonFile , {
311+ ...fileOptions ,
312+ name : path . relative ( root , packageJsonFile ) ,
313+ } )
304314 for ( const includePattern of include ) {
305- archive . glob ( includePattern , { cwd : path . join ( dir , '/' ) } , { mode } )
315+ archive . glob ( includePattern , { cwd : dir } , {
316+ ...fileOptions ,
317+ prefix,
318+ } )
306319 }
307320 for ( const filePath of extraFiles ) {
308- archive . file ( path . resolve ( dir , filePath ) , { name : filePath , mode } )
321+ archive . file ( path . resolve ( root , filePath ) , {
322+ ...fileOptions ,
323+ name : path . relative ( root , filePath ) ,
324+ } )
309325 }
310326}
311327
0 commit comments