11const { buildCommandExecutor} = require ( './commandExecutorBuilder' )
2- const { sleep, getFormedRunCommand, getSpecFilesPath , getPollTime} = require ( './helpers' )
2+ const { sleep, getFormedRunCommand, getFilesArray , getPollTime} = require ( './helpers' )
33
44function reRunnerBuilder ( runOptions ) {
55
@@ -8,12 +8,12 @@ function reRunnerBuilder(runOptions) {
88
99 const {
1010 stackAnalize,
11- specRerunCount : commandRunTriesCount ,
11+ attemptsCount ,
1212 grepWord,
1313 debugProcess,
14- reformatCommand : addCommandOptionsAfterRun ,
14+ reformatCommand,
1515 intervalPoll,
16- everyCycleCallback : afterSingleRunCallBack ,
16+ everyCycleCallback,
1717 specsDir,
1818 longestProcessTime,
1919 formCommanWithOption : addSpecificOptionsBeforeRun ,
@@ -33,20 +33,20 @@ function reRunnerBuilder(runOptions) {
3333 currentExecutionVariable,
3434 longestProcessTime,
3535 debugProcess,
36- addCommandOptionsAfterRun ,
36+ reformatCommand ,
3737 stackAnalize
3838 } )
3939
4040
4141 async function reRunner ( commandsArray ) {
4242 // if run arr was not defined as argument commandsArray will defined as default array
43- commandsArray = ( commandsArray || getSpecFilesPath ( specsDir )
43+ commandsArray = ( commandsArray || getFilesArray ( specsDir )
4444 . map ( ( file ) => getFormedRunCommand ( file ) ) )
4545 . filter ( function ( cmd ) { return cmd . includes ( grepWord ) } )
4646
47- const failedCommands = await new Array ( commandRunTriesCount )
47+ const failedCommands = await new Array ( attemptsCount )
4848 // create array with current length
49- . fill ( commandRunTriesCount )
49+ . fill ( attemptsCount )
5050 // execute run
5151 . reduce ( ( resolver , /*current*/ current , index ) => {
5252
@@ -85,8 +85,12 @@ function reRunnerBuilder(runOptions) {
8585 if ( currentSessionCount ) { await sleep ( 2000 ) }
8686 } while ( commands . length || currentSessionCount )
8787
88- if ( afterSingleRunCallBack && typeof afterSingleRunCallBack === 'function' ) {
89- try { await afterSingleRunCallBack ( ) } catch ( e ) { console . log ( e ) }
88+ if ( everyCycleCallback && typeof everyCycleCallback === 'function' ) {
89+ try {
90+ await everyCycleCallback ( )
91+ } catch ( e ) {
92+ console . log ( e )
93+ }
9094 }
9195
9296 clearInterval ( asserter )
@@ -110,7 +114,7 @@ function reRunnerBuilder(runOptions) {
110114module . exports = {
111115 buildExeRun : ( {
112116 maxSessionCount = 5 ,
113- specRerunCount = 2 ,
117+ attemptsCount = 2 ,
114118 stackAnalize,
115119 everyCycleCallback,
116120 reformatCommand,
@@ -127,7 +131,7 @@ module.exports = {
127131 debugProcess,
128132 longestProcessTime,
129133 maxSessionCount,
130- specRerunCount ,
134+ attemptsCount ,
131135 reformatCommand,
132136 stackAnalize,
133137 grepWord,
@@ -139,6 +143,6 @@ module.exports = {
139143 return reRunnerBuilder ( reformattedArgs )
140144 } ,
141145 sleep,
142- walkSync : getSpecFilesPath ,
146+ walkSync : getFilesArray ,
143147 getRunCommand : getFormedRunCommand
144148}
0 commit comments