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:
20
packages/hoppscotch-cli/src/options/test/delay.ts
Normal file
20
packages/hoppscotch-cli/src/options/test/delay.ts
Normal file
@@ -0,0 +1,20 @@
|
||||
import * as TE from "fp-ts/TaskEither";
|
||||
import * as S from "fp-ts/string";
|
||||
import { pipe } from "fp-ts/function";
|
||||
import { error, HoppCLIError } from "../../types/errors";
|
||||
|
||||
export const parseDelayOption = (
|
||||
delay: unknown
|
||||
): TE.TaskEither<HoppCLIError, number> =>
|
||||
!S.isString(delay)
|
||||
? TE.right(0)
|
||||
: pipe(
|
||||
delay,
|
||||
Number,
|
||||
TE.fromPredicate(Number.isSafeInteger, () =>
|
||||
error({
|
||||
code: "INVALID_ARGUMENT",
|
||||
data: "Expected '-d, --delay' value to be number",
|
||||
})
|
||||
)
|
||||
);
|
||||
Reference in New Issue
Block a user