@@ -233,12 +233,33 @@ exports.setAccessibilityEventListeners = (bsConfig) => {
233
233
// Searching form command.js recursively
234
234
const supportFilesData = helper . getSupportFiles ( bsConfig , true ) ;
235
235
if ( ! supportFilesData . supportFile ) return ;
236
+ const isPattern = glob . hasMagic ( supportFilesData . supportFile ) ;
237
+ if ( ! isPattern ) {
238
+ console . debug ( `Inside isPattern` ) ;
239
+ logger . debug ( `Inside isPattern` ) ;
240
+ const defaultFileContent = fs . readFileSync ( supportFilesData . supportFile , { encoding : 'utf-8' } ) ;
241
+
242
+ let cypressCommandEventListener = getAccessibilityCypressCommandEventListener ( path . extname ( supportFilesData . supportFile ) ) ;
243
+ if ( ! defaultFileContent . includes ( cypressCommandEventListener ) ) {
244
+ let newFileContent = defaultFileContent +
245
+ '\n' +
246
+ cypressCommandEventListener +
247
+ '\n'
248
+ fs . writeFileSync ( file , newFileContent , { encoding : 'utf-8' } ) ;
249
+ supportFileContentMap [ file ] = supportFilesData . cleanupParams ? supportFilesData . cleanupParams : defaultFileContent ;
250
+ }
251
+
252
+ }
236
253
glob ( process . cwd ( ) + supportFilesData . supportFile , { } , ( err , files ) => {
237
254
if ( err ) return logger . debug ( 'EXCEPTION IN BUILD START EVENT : Unable to parse cypress support files' ) ;
238
255
files . forEach ( file => {
239
256
try {
240
257
const fileName = path . basename ( file ) ;
241
- if ( ( fileName === 'e2e.js' || fileName === 'e2e.ts' ) ) {
258
+ console . debug ( `Adding accessibility event listeners to ${ fileName } ` ) ;
259
+ logger . debug ( `Adding accessibility event listeners to ${ fileName } ` ) ;
260
+ if ( ( fileName === 'e2e.js' || fileName === 'e2e.ts' || fileName === 'component.ts' || fileName === 'component.js' ) ) {
261
+ console . debug ( `Adding accessibility event listeners to ${ file } ` ) ;
262
+ logger . debug ( `Adding accessibility event listeners to ${ file } ` ) ;
242
263
const defaultFileContent = fs . readFileSync ( file , { encoding : 'utf-8' } ) ;
243
264
244
265
let cypressCommandEventListener = getAccessibilityCypressCommandEventListener ( path . extname ( file ) ) ;
0 commit comments