Skip to content

Commit 4d3ebd7

Browse files
committed
small fixes, backward compatibility
1 parent 0dbe888 commit 4d3ebd7

8 files changed

Lines changed: 25 additions & 20 deletions

File tree

.gitignore

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,4 +4,4 @@ package-lock.json
44
ex.js
55
spa-report
66
.idea
7-
playground.js
7+
playground.*

bin/rerun

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ process.title = 'protractor-rerun'
44

55
const path = require('path')
66
const fs = require('fs')
7-
const {walkSync, buildExeRun, getRunCommand} = require('../lib')
7+
const {getFilesList, buildExeRun, getRunCommand} = require('../lib')
88

99
const argv = require('minimist')(process.argv.slice(2))
1010

@@ -48,7 +48,7 @@ if(argv.protractor) {
4848
process.exit(1)
4949
}
5050

51-
const specFiles = walkSync(argv.specDir ? argv.specDir : defaultSpecDir)
51+
const specFiles = getFilesList(argv.specDir ? argv.specDir : defaultSpecDir)
5252
.filter((file) => file.includes(defaultBuilder.grepWord))
5353

5454
if(!specFiles.length) {

lib/execProc.js

Lines changed: 1 addition & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,6 @@
11
const {exec} = require('child_process');
22
const {returnStringType} = require('./helpers');
3-
4-
function millisecondsToMinutes(milliseconds) {
5-
const minutes = Math.floor(milliseconds / 60000);
6-
const seconds = ((milliseconds % 60000) / 1000).toFixed(0);
7-
return (seconds === '60' ? (minutes + 1) + ":00" : minutes + ":" + (seconds < 10 ? "0" : "") + seconds);
8-
}
3+
const {millisecondsToMinutes} = require('./utils')
94

105
function buildExecRunner(failedByAssert, runOpts) {
116
const {

lib/helpers.js

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -17,9 +17,11 @@ const getFormedRunCommand = (file, conf = path.resolve(process.cwd(), './protrac
1717
* @param {string} dir a path to the director what should be read
1818
* @param {array<string>} fileList option, empty array what will contains all files
1919
* @param {array<string>} directoryToSkip option, directories what should be exclude from files list
20+
* @param {boolean} ignoreSubDirs option, directories what should be exclude from files list
2021
* @returns {array<string>}
2122
*/
22-
const getFilesArray = function(dir, fileList = [], directoryToSkip = []) {
23+
const getFilesList = function(dir, fileList = [], directoryToSkip = [], ignoreSubDirs) {
24+
2325
const files = fs.readdirSync(dir)
2426
files.forEach(function(file) {
2527
const isDirr = fs.statSync(path.join(dir, file)).isDirectory()
@@ -30,8 +32,8 @@ const getFilesArray = function(dir, fileList = [], directoryToSkip = []) {
3032

3133
if(shouldBeExcluded) {return }
3234

33-
if(isDirr) {
34-
fileList = getFilesArray(path.join(dir, file), fileList, directoryToSkip)
35+
if(isDirr && !ignoreSubDirs) {
36+
fileList = getFilesList(path.join(dir, file), fileList, directoryToSkip, ignoreSubDirs)
3537
} else {
3638
fileList.push(path.join(dir, file))
3739
}
@@ -60,6 +62,6 @@ module.exports = {
6062
getFormedRunCommand,
6163
getPollTime,
6264
sleep,
63-
getFilesArray,
65+
getFilesList,
6466
returnStringType
6567
}

lib/index.js

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
const {buildCommandExecutor} = require('./commandExecutorBuilder')
2-
const {sleep, getFormedRunCommand, getFilesArray, getPollTime} = require('./helpers')
2+
const {sleep, getFormedRunCommand, getFilesList, getPollTime} = require('./helpers')
33

44
function reRunnerBuilder(runOptions) {
55

@@ -42,7 +42,7 @@ function reRunnerBuilder(runOptions) {
4242

4343
async function reRunner(commandsArray) {
4444
// if run arr was not defined as argument commandsArray will defined as default array
45-
commandsArray = (commandsArray || getFilesArray(specsDir)
45+
commandsArray = (commandsArray || getFilesList(specsDir)
4646
.map((file) => getFormedRunCommand(file)))
4747
.filter(function(cmd) {return cmd.includes(grepWord)})
4848

@@ -165,6 +165,6 @@ module.exports = {
165165
return reRunnerBuilder(reformattedArgs)
166166
},
167167
sleep,
168-
walkSync: getFilesArray,
168+
getFilesList,
169169
getRunCommand: getFormedRunCommand
170170
}

lib/utils.js

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,13 @@ function executionWatcher(debugProcess, currentTime, limitTime, intervalWatcher,
1818
}
1919
};
2020

21+
function millisecondsToMinutes(milliseconds) {
22+
const minutes = Math.floor(milliseconds / 60000);
23+
const seconds = ((milliseconds % 60000) / 1000).toFixed(0);
24+
return (seconds === '60' ? (minutes + 1) + ":00" : minutes + ":" + (seconds < 10 ? "0" : "") + seconds);
25+
}
26+
2127
module.exports = {
22-
executionWatcher
28+
executionWatcher,
29+
millisecondsToMinutes
2330
}

package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "process-rerun",
3-
"version": "0.0.15",
3+
"version": "0.0.17",
44
"bin": {
55
"protractor-rerun": "./bin/rerun"
66
},

rerun.js

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,12 @@
11

2-
const {walkSync, buildExeRun} = require('./lib')
2+
const {getFilesList, buildExeRun} = require('./lib')
33

44
module.exports = {
55
getReruner: function(optsObj) {
66
return buildExeRun(optsObj)
77
},
8-
getSpecFilesArr: walkSync,
8+
getFilesList,
9+
getSpecFilesArr: getFilesList,
910
getSpecCommands: function(pathToSpecDir, getRunCommandPattern) {
1011
return walkSync(pathToSpecDir).map(getRunCommandPattern)
1112
}

0 commit comments

Comments
 (0)