Skip to content

Instantly share code, notes, and snippets.

@wayneseymour
Created March 3, 2021 16:47
Show Gist options
  • Save wayneseymour/d31f108495a7226344d08f1c324fffee to your computer and use it in GitHub Desktop.
Save wayneseymour/d31f108495a7226344d08f1c324fffee to your computer and use it in GitHub Desktop.
import { ToolingLog } from '@kbn/dev-utils';
import { SuperTest } from 'supertest';
// @ts-ignore
import * as Either from '../../../../src/dev/code_coverage/ingest_coverage/either';
const id = (x: any = null) => x;
const recurseEither = (max: number) => (x: number) =>
max > x ? Either.right(x) : Either.left(x);
export const recurseList = (f: any) => (log: ToolingLog) => (supertest: SuperTest<any>) => async (
names: any,
i: number = 1
) => {
const appName = names[i - 1];
await f()(log)(supertest)(appName);
recurseEither(names.length)(i) // Recurses only when names.length is less than i
.fold(id, async () => {
i++;
await recurseList(f)(log)(supertest)(names, i);
});
};
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment