Skip to content

Commit

Permalink
fix: add "--report-files-glob" to "compare-reports" (#26)
Browse files Browse the repository at this point in the history
  • Loading branch information
layershifter authored Dec 22, 2023
1 parent 54b1dd5 commit e00f11d
Show file tree
Hide file tree
Showing 3 changed files with 21 additions and 3 deletions.
7 changes: 7 additions & 0 deletions change/monosize-8210a1a9-68b9-4ddb-891f-b0765eb56ceb.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
{
"type": "patch",
"comment": "fix: add \"--report-files-glob\" to \"compare-reports\"",
"packageName": "monosize",
"email": "[email protected]",
"dependentChangeType": "patch"
}
15 changes: 13 additions & 2 deletions packages/monosize/src/commands/compareReports.mts
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,11 @@ import { compareResultsInReports } from '../utils/compareResultsInReports.mjs';
import { hrToSeconds } from '../utils/helpers.mjs';
import { readConfig } from '../utils/readConfig.mjs';

export type CompareReportsOptions = CliOptions & { branch: string; output: 'cli' | 'markdown' };
export type CompareReportsOptions = CliOptions & {
branch: string;
'report-files-glob'?: string;
output: 'cli' | 'markdown';
};

async function compareReports(options: CompareReportsOptions) {
const { branch, output, quiet } = options;
Expand All @@ -18,7 +22,9 @@ async function compareReports(options: CompareReportsOptions) {
const config = await readConfig(quiet);

const localReportStartTime = process.hrtime();
const localReport = await collectLocalReport();
const localReport = await collectLocalReport({
...(options['report-files-glob'] && { reportFilesGlob: options['report-files-glob'] }),
});

if (!quiet) {
console.log(
Expand Down Expand Up @@ -70,6 +76,11 @@ const api: CommandModule<Record<string, unknown>, CompareReportsOptions> = {
description: 'A branch to compare against',
default: 'main',
},
'report-files-glob': {
type: 'string',
description: 'A glob pattern to search for report files in JSON format',
required: false,
},
output: {
alias: 'o',
type: 'string',
Expand Down
2 changes: 1 addition & 1 deletion packages/monosize/src/commands/uploadReport.mts
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ import { hrToSeconds } from '../utils/helpers.mjs';
import { readConfig } from '../utils/readConfig.mjs';
import type { CliOptions } from '../index.mjs';

type UploadOptions = CliOptions & { branch: string; 'report-files-glob': string; 'commit-sha': string };
type UploadOptions = CliOptions & { branch: string; 'report-files-glob'?: string; 'commit-sha': string };

async function uploadReport(options: UploadOptions) {
if (!isCI) {
Expand Down

0 comments on commit e00f11d

Please sign in to comment.