Skip to content

Commit

Permalink
feat(utils): Pass source options to extraction fns
Browse files Browse the repository at this point in the history
  • Loading branch information
vio committed Nov 16, 2021
1 parent efc93d3 commit 65dc741
Show file tree
Hide file tree
Showing 3 changed files with 6 additions and 6 deletions.
4 changes: 2 additions & 2 deletions packages/utils/src/jobs/create-job.js
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ const GENERIC_PROPS = ['meta', 'insights', 'metrics'];
/*
* Create job from stats
*/
export const createJob = (source, baseline) => SOURCE_PATHS.reduce((agg, sourcePath) => {
export const createJob = (source, baseline, options = {}) => SOURCE_PATHS.reduce((agg, sourcePath) => {
const rawData = get(source, sourcePath);

if (!rawData) {
Expand All @@ -27,7 +27,7 @@ export const createJob = (source, baseline) => SOURCE_PATHS.reduce((agg, sourceP
return agg;
}

const extractedData = sourceModule.extract(rawData, baseline);
const extractedData = sourceModule.extract(rawData, baseline, options[sourcePath]);
const summary = createSummary(
SOURCE_FNS[sourcePath].SUMMARY_METRIC_PATHS,
get(baseline, `metrics.${sourcePath}`, {}),
Expand Down
4 changes: 2 additions & 2 deletions packages/utils/src/jobs/create-jobs.js
Original file line number Diff line number Diff line change
Expand Up @@ -6,9 +6,9 @@ import { createJob } from './create-job';
/*
* Create jobs from sources
*/
export const createJobs = (sources) => {
export const createJobs = (sources, options) => {
const jobs = reverse([...sources]).reduce((agg, source, idx) => {
const job = createJob(source, last(agg));
const job = createJob(source, last(agg), options);
const internalBuildNumber = job.internalBuildNumber || idx + 1;
const label = `Job #${internalBuildNumber}`;

Expand Down
4 changes: 2 additions & 2 deletions packages/utils/src/webpack/extract/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -30,11 +30,11 @@ const extractFns = [
extractBudgetsInsights,
];

export const extract = (webpackStats, baseline) => extractFns.reduce(
export const extract = (webpackStats, baseline, options) => extractFns.reduce(
(agg, extractFn) => merge(
{},
agg,
extractFn(webpackStats, agg, baseline),
extractFn(webpackStats, agg, baseline, options),
),
{}
);

0 comments on commit 65dc741

Please sign in to comment.