Skip to content

Commit

Permalink
fix(cli-utils): Add log entry for baseline writing
Browse files Browse the repository at this point in the history
  • Loading branch information
vio committed Jan 24, 2024
1 parent 98d0b18 commit 8b22b89
Show file tree
Hide file tree
Showing 3 changed files with 9 additions and 4 deletions.
8 changes: 6 additions & 2 deletions packages/cli-utils/src/reports.ts
Original file line number Diff line number Diff line change
Expand Up @@ -115,10 +115,10 @@ export const generateReports = async (
baselineStats = filter(baselineStatsData);

if (!options.silent) {
logger.info(`${TEXT.BASELINE_READING} ${baselinePath}`);
logger.info(`${TEXT.BASELINE_READING} ${baselinePath}.`);
}
} catch (err) {
logger.warn(TEXT.BASELINE_MISSING);
logger.warn(`${TEXT.BASELINE_READING} ${baselinePath}. ${TEXT.BASELINE_MISSING}`);
}
}

Expand Down Expand Up @@ -150,6 +150,10 @@ export const generateReports = async (
source: JSON.stringify(data),
filepath: baselineAbsolutePath,
};

if (!options.silent) {
logger.info(`${TEXT.BASELINE_WRITING} ${baselinePath}`);
}
}

const info = getReportInfo(report);
Expand Down
1 change: 1 addition & 0 deletions packages/cli-utils/src/text.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
export const BASELINE_MISSING = 'Baseline stats file is missing, see "baseline" option.';
export const BASELINE_READING = 'Reading baseline data from';
export const BASELINE_WRITING = 'Writing baseline data to';

export const CLI_NO_COMPARE_MODE = 'Not in compare mode (see --compare).';
export const CLI_MULTIPLE_STATS = 'Multiple stat files already set.';
Expand Down
4 changes: 2 additions & 2 deletions packages/webpack-plugin/src/__tests__/webpack-plugin.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -116,7 +116,7 @@ describe('webpack plugin', () => {
/* eslint-disable no-console */
expect(console.warn).not.toBeCalledWith('Missing baseline stats, see "baseline" option.');
expect(console.info).toBeCalledWith(
'Reading baseline data from ../node_modules/.cache/bundle-stats/baseline.json',
'Reading baseline data from ../node_modules/.cache/bundle-stats/baseline.json.',
);
expect(console.info).toBeCalledWith('Bundle Size — 27B (+35%).');
/* eslint-enable no-console */
Expand Down Expand Up @@ -151,7 +151,7 @@ describe('webpack plugin', () => {

/* eslint-disable no-console */
expect(console.warn).not.toBeCalledWith('Missing baseline stats, see "baseline" option.');
expect(console.info).toBeCalledWith('Reading baseline data from custom-baseline.json');
expect(console.info).toBeCalledWith('Reading baseline data from custom-baseline.json.');
expect(console.info).toBeCalledWith('Bundle Size — 27B (+8%).');
/* eslint-enable no-console */

Expand Down

0 comments on commit 8b22b89

Please sign in to comment.