Skip to content

Commit

Permalink
Meta: Clean up scripts/insert_warning.mjs
Browse files Browse the repository at this point in the history
  • Loading branch information
gibson042 committed Dec 28, 2024
1 parent aa8e2c3 commit b391359
Showing 1 changed file with 7 additions and 4 deletions.
11 changes: 7 additions & 4 deletions scripts/insert_warning.mjs
Original file line number Diff line number Diff line change
Expand Up @@ -48,6 +48,11 @@ const main = async args => {
(node.matches?.('link:not([itemprop])') &&
[...node.relList].some(rel => !rel.match(bodyOkRelPatt)));
const insertDom = JSDOM.fragment(resolved);
// Node.js v22+:
// const { headInserts, bodyInserts } = Object.groupBy(
// insertDom.childNodes,
// node => (forceHead(node) ? 'headInserts' : 'bodyInserts'),
// );
const headInserts = [], bodyInserts = [];
for (const node of insertDom.childNodes) {
if (forceHead(node)) headInserts.push(node);
Expand All @@ -69,10 +74,8 @@ const main = async args => {
fs.writeFileSync(file, dom.serialize(), 'utf8');
}));

const failures = results.flatMap(result =>
result.status === 'fulfilled' ? [] : [result.reason],
);
if (failures.length > 0) throw AggregateError(failures);
const failures = results.filter(result => result.status !== 'fulfilled');
if (failures.length > 0) throw AggregateError(failures.map(r => r.reason));
};

main(cliArgs).catch(err => {
Expand Down

0 comments on commit b391359

Please sign in to comment.