File tree Expand file tree Collapse file tree 2 files changed +12
-9
lines changed Expand file tree Collapse file tree 2 files changed +12
-9
lines changed Original file line number Diff line number Diff line change @@ -377,19 +377,22 @@ const getCypressCommandEventListener = () => {
377
377
378
378
const setEventListeners = ( ) => {
379
379
try {
380
+ const cypressCommandEventListener = getCypressCommandEventListener ( ) ;
380
381
glob ( process . cwd ( ) + '/cypress/support/*.js' , { } , ( err , files ) => {
381
382
if ( err ) return exports . debug ( 'EXCEPTION IN BUILD START EVENT : Unable to parse cypress support files' ) ;
382
383
files . forEach ( file => {
383
384
try {
384
385
if ( ! file . includes ( 'commands.js' ) ) {
385
386
const defaultFileContent = fs . readFileSync ( file , { encoding : 'utf-8' } ) ;
386
-
387
- let newFileContent = defaultFileContent +
387
+
388
+ if ( ! defaultFileContent . includes ( cypressCommandEventListener ) ) {
389
+ let newFileContent = defaultFileContent +
388
390
'\n' +
389
- getCypressCommandEventListener ( ) +
391
+ cypressCommandEventListener +
390
392
'\n'
391
- fs . writeFileSync ( file , newFileContent , { encoding : 'utf-8' } ) ;
392
- supportFileContentMap [ file ] = defaultFileContent ;
393
+ fs . writeFileSync ( file , newFileContent , { encoding : 'utf-8' } ) ;
394
+ supportFileContentMap [ file ] = defaultFileContent ;
395
+ }
393
396
}
394
397
} catch ( e ) {
395
398
exports . debug ( `Unable to modify file contents for ${ file } to set event listeners with error ${ e } ` , true , e ) ;
Original file line number Diff line number Diff line change @@ -4,12 +4,12 @@ const util = require('util');
4
4
const fs = require ( 'fs' ) ;
5
5
const path = require ( 'path' ) ;
6
6
const { requireModule } = require ( '../helper/helper' ) ;
7
- const Base = requireModule ( 'mocha/lib/reporters/base.js' , true ) ,
8
- utils = requireModule ( 'mocha/lib/utils.js' , true ) ;
7
+ const Base = requireModule ( 'mocha/lib/reporters/base.js' ) ,
8
+ utils = requireModule ( 'mocha/lib/utils.js' ) ;
9
9
const color = Base . color ;
10
- const Mocha = requireModule ( 'mocha' , true ) ;
10
+ const Mocha = requireModule ( 'mocha' ) ;
11
11
// const Runnable = requireModule('mocha/lib/runnable');
12
- const Runnable = require ( 'mocha/lib/runnable' , true ) ; // need to handle as this isn't present in older mocha versions
12
+ const Runnable = require ( 'mocha/lib/runnable' ) ; // need to handle as this isn't present in older mocha versions
13
13
const { v4 : uuidv4 } = require ( 'uuid' ) ;
14
14
15
15
const { IPC_EVENTS } = require ( '../helper/constants' ) ;
You can’t perform that action at this time.
0 commit comments