Skip to content

Commit

Permalink
refactor: workspaces initial value
Browse files Browse the repository at this point in the history
  • Loading branch information
mxdvl committed Jan 12, 2023
1 parent b54d497 commit 0badf78
Showing 1 changed file with 27 additions and 27 deletions.
54 changes: 27 additions & 27 deletions scripts/deno/peer-dependencies.ts
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,9 @@ const peers = async (cwd: string) => {
return deps;
};

type Workspaces = { dcr: string[]; cr: string[]; ar: string[] };
const initialValue: Workspaces = { dcr: [], cr: [], ar: [] };

const { dcr, ar, cr } = (
await Promise.all(['.', './apps-rendering'].map(peers))
)
Expand All @@ -42,33 +45,30 @@ const { dcr, ar, cr } = (

return { workspace, dependency, peer };
})
.reduce<{ dcr: string[]; cr: string[]; ar: string[] }>(
(acc, { workspace, dependency, peer }) => {
const line = `- [ ] \`${dependency}\` requires peer \`${peer}\``;
switch (workspace) {
case '@guardian/dotcom-rendering':
return {
...acc,
dcr: acc.dcr.concat(line),
};

case '@guardian/common-rendering':
return {
...acc,
cr: acc.cr.concat(line),
};

case '@guardian/apps-rendering':
return {
...acc,
ar: acc.ar.concat(line),
};
default:
return acc;
}
},
{ dcr: [], cr: [], ar: [] },
);
.reduce<Workspaces>((acc, { workspace, dependency, peer }) => {
const line = `- [ ] \`${dependency}\` requires peer \`${peer}\``;
switch (workspace) {
case '@guardian/dotcom-rendering':
return {
...acc,
dcr: acc.dcr.concat(line),
};

case '@guardian/common-rendering':
return {
...acc,
cr: acc.cr.concat(line),
};

case '@guardian/apps-rendering':
return {
...acc,
ar: acc.ar.concat(line),
};
default:
return acc;
}
}, initialValue);

const body = `## Current peer dependencies mismatch
Expand Down

0 comments on commit 0badf78

Please sign in to comment.