@@ -244,14 +244,12 @@ exports.setAccessibilityEventListeners = (bsConfig) => {
244
244
}
245
245
246
246
// Build the correct glob pattern
247
- const resolvedPath = path . resolve ( process . cwd ( ) , supportFilesData . supportFile ) ;
248
- if ( ! resolvedPath . startsWith ( process . cwd ( ) ) ) {
249
- throw new Error ( 'Path traversal attempt detected' ) ;
250
- }
251
- const globPattern = supportFilesData . supportFile . startsWith ( '/' )
252
- ? process . cwd ( ) + supportFilesData . supportFile
253
- : resolvedPath ;
254
-
247
+ // const globPattern = supportFilesData.supportFile.startsWith('/')
248
+ // ? process.cwd() + supportFilesData.supportFile
249
+ // : path.resolve(process.cwd(), supportFilesData.supportFile);
250
+
251
+ const globPattern = process . cwd ( ) + supportFilesData . supportFile ;
252
+ console . log ( `Using glob pattern to find support files: ${ globPattern } ` ) ;
255
253
glob ( globPattern , { } , ( err , files ) => {
256
254
if ( err ) {
257
255
logger . debug ( 'EXCEPTION IN BUILD START EVENT : Unable to parse cypress support files' ) ;
@@ -261,26 +259,31 @@ exports.setAccessibilityEventListeners = (bsConfig) => {
261
259
files . forEach ( file => {
262
260
try {
263
261
const fileName = path . basename ( file ) ;
262
+ console . log ( `Found support file: ${ file } ` ) ;
263
+ console . log ( `File name: ${ fileName } ` ) ;
264
264
if ( [ 'e2e.js' , 'e2e.ts' , 'component.ts' , 'component.js' ] . includes ( fileName ) && ! file . includes ( 'node_modules' ) ) {
265
265
266
266
const defaultFileContent = fs . readFileSync ( file , { encoding : 'utf-8' } ) ;
267
267
let cypressCommandEventListener = getAccessibilityCypressCommandEventListener ( path . extname ( file ) ) ;
268
-
268
+ console . log ( `Cypress command event listener: ${ cypressCommandEventListener } ` ) ;
269
269
if ( ! defaultFileContent . includes ( cypressCommandEventListener ) ) {
270
270
let newFileContent = defaultFileContent +
271
271
'\n' +
272
272
cypressCommandEventListener +
273
273
'\n' ;
274
274
fs . writeFileSync ( file , newFileContent , { encoding : 'utf-8' } ) ;
275
+ console . log ( `Updated file content for ${ file } : ${ newFileContent } ` ) ;
275
276
supportFileContentMap [ file ] = supportFilesData . cleanupParams ? supportFilesData . cleanupParams : defaultFileContent ;
276
277
}
277
278
}
278
279
} catch ( e ) {
280
+ console . log ( `Error updating file content for ${ file } : ${ e } ` ) ;
279
281
logger . debug ( `Unable to modify file contents for ${ file } to set event listeners with error ${ e } ` , true , e ) ;
280
282
}
281
283
} ) ;
282
284
} ) ;
283
285
} catch ( e ) {
286
+ console . log ( `Error updating file content for2 ${ file } : ${ e } ` ) ;
284
287
logger . debug ( `Unable to parse support files to set event listeners with error ${ e } ` , true , e ) ;
285
288
}
286
289
}
0 commit comments