Skip to content

Commit e05356f

Browse files
committed
add in progress commands to logger
1 parent c5511f0 commit e05356f

3 files changed

Lines changed: 18 additions & 4 deletions

File tree

lib/executor.circle.ts

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -43,6 +43,7 @@ async function circleExecutor(runOptions, commandsArray): Promise<{ retriable: s
4343
* commandsArray = toArray(commandsArray);
4444
*/
4545
commandsArray = toArray(commandsArray);
46+
const inProgressCommands = [];
4647

4748
logStartCycle(maxThreads, attemptsCount, commandsArray);
4849

@@ -68,9 +69,13 @@ async function circleExecutor(runOptions, commandsArray): Promise<{ retriable: s
6869

6970
const commandToExecute = commands.splice(0, 1)[0];
7071
if (isString(commandToExecute)) {
72+
const index = inProgressCommands.push(commandToExecute) - 1;
7173
result = await executeCommandAsync(commandToExecute, runIndex).catch(error => logger.error(error));
74+
inProgressCommands.splice(index, 1);
7275
} else if (isFunction(commandToExecute) || isAsyncFunction(commandToExecute)) {
76+
const index = inProgressCommands.push(commandToExecute.toString()) - 1;
7377
result = await commandToExecute(runIndex).catch(error => logger.error(error));
78+
inProgressCommands.splice(index, 1);
7479
}
7580

7681
if (result) {
@@ -87,7 +92,8 @@ async function circleExecutor(runOptions, commandsArray): Promise<{ retriable: s
8792
const asserter = setInterval(() => runCommand(commands, retriable, executionCount), pollTime);
8893

8994
const logProcessesProgressLogger =
90-
logProcessesProgress && setInterval(() => logMiddleResultsCycle(initialCommandsCount, commands), 5000);
95+
logProcessesProgress &&
96+
setInterval(() => logMiddleResultsCycle(initialCommandsCount, commands, inProgressCommands), 5000);
9197

9298
const watcherRunner = watcher && setInterval(watcher, 5000);
9399

lib/executor.intime.ts

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -47,6 +47,7 @@ async function intimeExecutor(runOptions, commandsArray): Promise<{ retriable: s
4747
cmd,
4848
}));
4949

50+
const inProgressCommands = [];
5051
logStartCycle(maxThreads, attemptsCount, inTimeCommands);
5152

5253
async function runCommand(commands) {
@@ -60,11 +61,15 @@ async function intimeExecutor(runOptions, commandsArray): Promise<{ retriable: s
6061

6162
const executionIndex = commadData.attemptsCount--;
6263
if (isString(commadData.cmd)) {
64+
const index = inProgressCommands.push(commadData.cmd) - 1;
6365
result = await executeCommandAsync(commadData.cmd, attemptsCount - executionIndex).catch(error =>
6466
logger.error(error),
6567
);
68+
inProgressCommands.splice(index, 1);
6669
} else if (isFunction(commadData.cmd) || isAsyncFunction(commadData.cmd)) {
70+
const index = inProgressCommands.push(commadData.cmd.toString()) - 1;
6771
result = await commadData.cmd(attemptsCount - executionIndex).catch(error => logger.error(error));
72+
inProgressCommands.splice(index, 1);
6873
}
6974

7075
if (result) {
@@ -80,12 +85,15 @@ async function intimeExecutor(runOptions, commandsArray): Promise<{ retriable: s
8085
currentSessionCount -= 1;
8186
}
8287
}
88+
8389
async function runCommandsArray(commands: any[]) {
8490
const initialCommandsCount = commands.length;
8591
const asserter = setInterval(() => runCommand(commands), pollTime);
8692

8793
const logProcessesProgressLoggerRunner =
88-
logProcessesProgress && setInterval(() => logMiddleResultsCycle(initialCommandsCount, commands), 5000);
94+
logProcessesProgress &&
95+
setInterval(() => logMiddleResultsCycle(initialCommandsCount, commands, inProgressCommands), 5000);
96+
8997
const watcherRunner = watcher && setInterval(watcher, 5000);
9098

9199
do {

package.json

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "process-rerun",
3-
"version": "0.4.0",
3+
"version": "0.4.1",
44
"repository": {
55
"type": "git",
66
"url": "git+https://github.com/potapovDim/protractor-rerun.git"
@@ -10,7 +10,7 @@
1010
"tscw": "tsc -w",
1111
"validate": "npm ls",
1212
"test": "mocha $(find specs -name '*.spec.*') --timeout 500000 --require ts-node/register",
13-
"build": "rm -rf ./built && tsc",
13+
"tsc": "rm -rf ./built && tsc",
1414
"lint": "eslint --ext .ts ./ --fix"
1515
},
1616
"author": {

0 commit comments

Comments
 (0)