feat: added delay flag in @hoppscotch/cli and related tests (#2527)

Co-authored-by: Andrew Bastin <andrewbastin.k@gmail.com>
This commit is contained in:
Deepanshu Dhruw
2022-08-04 19:19:14 +05:30
committed by GitHub
parent 0c31d9201f
commit 73fdfbd2c8
13 changed files with 162 additions and 18 deletions

View File

@@ -5,7 +5,12 @@ import { bold } from "chalk";
import { log } from "console";
import round from "lodash/round";
import { HoppCollection, HoppRESTRequest } from "@hoppscotch/data";
import { HoppEnvs, CollectionStack, RequestReport } from "../types/request";
import {
HoppEnvs,
CollectionStack,
RequestReport,
ProcessRequestParams,
} from "../types/request";
import {
getRequestMetrics,
preProcessRequest,
@@ -41,6 +46,7 @@ export const collectionsRunner =
(param: CollectionRunnerParam): T.Task<RequestReport[]> =>
async () => {
const envs: HoppEnvs = param.envs;
const delay = param.delay ?? 0;
const requestsReport: RequestReport[] = [];
const collectionStack: CollectionStack[] = getCollectionStack(
param.collections
@@ -54,12 +60,18 @@ export const collectionsRunner =
for (const request of collection.requests) {
const _request = preProcessRequest(request);
const requestPath = `${path}/${_request.name}`;
const processRequestParams: ProcessRequestParams = {
path: requestPath,
request: _request,
envs,
delay,
};
// Request processing initiated message.
log(WARN(`\nRunning: ${bold(requestPath)}`));
// Processing current request.
const result = await processRequest(_request, envs, requestPath)();
const result = await processRequest(processRequestParams)();
// Updating global & selected envs with new envs from processed-request output.
const { global, selected } = result.envs;