Skip to content

Commit

Permalink
Revert "#208 Added loop for running infinite, number of times and wit…
Browse files Browse the repository at this point in the history
…h specific interval"

This reverts commit 91d339c.
  • Loading branch information
czprz authored May 18, 2023
1 parent e31a0b6 commit dbd7f13
Show file tree
Hide file tree
Showing 4 changed files with 4 additions and 64 deletions.
30 changes: 0 additions & 30 deletions bin/common/executor/models.js
Original file line number Diff line number Diff line change
Expand Up @@ -101,39 +101,9 @@ export class ExecutionInterface {
* @param runtime {Runtime}
*/
async handle(execute, runtime) {
if (runtime.times != null) {
await this.#run(execute, runtime);
return;
}

await this._execute(execute, runtime);
}

/**
* Run command multiple times
* @param execute {Execute}
* @param runtime {Runtime}
* @returns {Promise<void>}
*/
async #run(execute, runtime) {
let count = 1;
let completed = false;

while (!completed) {
await this._execute(execute, runtime);

if (runtime.times !== 0 && count === runtime.times) {
completed = true;
} else {
await new Promise(resolve => setTimeout(resolve, runtime.interval));
}

if (runtime.times > 0) {
count++;
}
}
}

/**
* @return {Promise<ExecutionLog>}
*/
Expand Down
18 changes: 0 additions & 18 deletions bin/common/models/common.js
Original file line number Diff line number Diff line change
Expand Up @@ -11,12 +11,6 @@ export class Args {
*/
down;

/**
* Option for running environment
* @type {string}
*/
run;

/**
* Starts one or more groups of executions
* @type {boolean|string|string[]}
Expand All @@ -29,18 +23,6 @@ export class Args {
*/
downGroup;

/**
* Number of times to run
* @type {number|null}
*/
times;

/**
* Interval between each run
* @type {number|null}
*/
interval;

/**
* Option (optional) included with start for starting environment cleanly
* @type {boolean}
Expand Down
4 changes: 3 additions & 1 deletion bin/execution/executor/executor-yargs-generator.js
Original file line number Diff line number Diff line change
Expand Up @@ -93,7 +93,8 @@ export default new class {
yargs
.positional('name', {
describe: 'Name of the action',
type: 'string'
type: 'string',
demandOption: true
})
.option('times', {
alias: 't',
Expand All @@ -111,6 +112,7 @@ export default new class {
customOptionsYargsCreator.addToYargs(yargs, segment.actions)
},
handler: (argv) => {
// TODO: Implement
this.#execute(segment, project, argv).catch(console.error);
}
})
Expand Down
16 changes: 1 addition & 15 deletions bin/execution/executor/runtime-mapper.js
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ export default new class {
* @returns {Runtime}
*/
getRuntime(args) {
const up = this.#hasValue(args, 'up') || this.#hasValue(args, 'run');
const up = this.#hasValue(args, 'up');
const down = this.#hasValue(args, 'down');
const upGroup = this.#hasValue(args, 'up-group');
const downGroup = this.#hasValue(args, 'down-group');
Expand All @@ -20,8 +20,6 @@ export default new class {
return {
up: up || upGroup,
down: down || downGroup,
times: args.times,
interval: args.interval,
include: {
executions: up || down ? this.#getVariables(args['name']) : [],
groups: upGroup || downGroup ? this.#getVariables(args[`name`]) : []
Expand Down Expand Up @@ -66,18 +64,6 @@ export class Runtime {
*/
down;

/**
* Times to run the actions
* @type {number | null}
*/
times;

/**
* Interval between each run
* @type {number | null}
*/
interval;

/**
* List of groups and executions to be included in starting or stopping
* @type { { executions: string[], groups: string[] } | null }
Expand Down

0 comments on commit dbd7f13

Please sign in to comment.