Skip to content

Commit b391359

Browse files
committed
Meta: Clean up scripts/insert_warning.mjs
1 parent aa8e2c3 commit b391359

File tree

1 file changed

+7
-4
lines changed

1 file changed

+7
-4
lines changed

scripts/insert_warning.mjs

Lines changed: 7 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -48,6 +48,11 @@ const main = async args => {
4848
(node.matches?.('link:not([itemprop])') &&
4949
[...node.relList].some(rel => !rel.match(bodyOkRelPatt)));
5050
const insertDom = JSDOM.fragment(resolved);
51+
// Node.js v22+:
52+
// const { headInserts, bodyInserts } = Object.groupBy(
53+
// insertDom.childNodes,
54+
// node => (forceHead(node) ? 'headInserts' : 'bodyInserts'),
55+
// );
5156
const headInserts = [], bodyInserts = [];
5257
for (const node of insertDom.childNodes) {
5358
if (forceHead(node)) headInserts.push(node);
@@ -69,10 +74,8 @@ const main = async args => {
6974
fs.writeFileSync(file, dom.serialize(), 'utf8');
7075
}));
7176

72-
const failures = results.flatMap(result =>
73-
result.status === 'fulfilled' ? [] : [result.reason],
74-
);
75-
if (failures.length > 0) throw AggregateError(failures);
77+
const failures = results.filter(result => result.status !== 'fulfilled');
78+
if (failures.length > 0) throw AggregateError(failures.map(r => r.reason));
7679
};
7780

7881
main(cliArgs).catch(err => {

0 commit comments

Comments
 (0)