Skip to content

Commit

Permalink
fix: fix typing issues
Browse files Browse the repository at this point in the history
  • Loading branch information
ChristopherPHolder committed Mar 6, 2024
1 parent c386662 commit 9bc03fe
Show file tree
Hide file tree
Showing 4 changed files with 16 additions and 5 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ import { persistFlow } from '../utils/persist/persist-flow';
import { handleOpenFlowReports } from '../utils/persist/open-report';
import { RcJson } from '../../../types';

export async function collectReports(cfg: RcJson, openReport: boolean): Promise<RcJson> {
export async function collectReports(cfg: RcJson, openReport?: boolean): Promise<RcJson> {

const { collect, persist, assert } = cfg;

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ export async function openFlowReports(fileNames: string[]): Promise<void> {
return Promise.resolve(void 0);
}

export function handleOpenFlowReports(openReport: boolean): typeof openFlowReports | undefined {
export function handleOpenFlowReports(openReport?: boolean): typeof openFlowReports | undefined {
if (dryRun() || !openReport || !interactive()) {
return;
}
Expand Down
15 changes: 13 additions & 2 deletions packages/cli/src/lib/commands/init/utils.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,17 @@
import { CollectRcOptions, PersistRcOptions } from '../collect/options/types';
import { CollectRcOptions, PersistRcOptions, ReportFormat } from '../collect/options/types';
import { InitOptions } from './options';
import { AssertRcOptions } from '../assert/options';
import { REPORT_FORMAT_VALUES } from '../collect/constants';

const isValidFormat = (value: any): value is ReportFormat => REPORT_FORMAT_VALUES.includes(value);

function sanitizedFormats(formats: string[]): ReportFormat[] {
const validatedFormats: ReportFormat[] = formats.filter(isValidFormat);
if (validatedFormats.length !== formats.length) {
throw new Error(`${formats} contains invalid format options`);
}
return validatedFormats;
}

export function getInitCommandOptionsFromArgv(argv: InitOptions) {
let {
Expand All @@ -18,7 +29,7 @@ export function getInitCommandOptionsFromArgv(argv: InitOptions) {

let persist = {} as PersistRcOptions;
outPath && (persist.outPath = outPath);
format && (persist.format = format);
format && (persist.format = sanitizedFormats(format));

let assert = {} as AssertRcOptions;
budgetPath && (assert.budgetPath = budgetPath);
Expand Down
2 changes: 1 addition & 1 deletion packages/cli/src/lib/pre-set.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import { ArgvPreset } from './types';
import { detectCliMode } from './global/cli-mode/cli-mode';
import { detectCliMode } from './global/cli-mode';
import { DEFAULT_FULL_RC_PATH } from './constants';

export const DEFAULT_PRESET: ArgvPreset = {
Expand Down

0 comments on commit 9bc03fe

Please sign in to comment.