Skip to content
This repository was archived by the owner on Jun 4, 2024. It is now read-only.

Commit aea3d2b

Browse files
committed
error message if element count changes from expectation
1 parent 72c97cc commit aea3d2b

File tree

1 file changed

+7
-0
lines changed

1 file changed

+7
-0
lines changed

scripts/extract-elements.js

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@ const request = require('request');
66

77
const refUrl = 'https://developer.mozilla.org/en-US/docs/Web/HTML/Element';
88
const dataPath = './data/elements.txt';
9+
const expectedElCount = 131;
910

1011
/**
1112
* From the MDN HTML elements reference, extract a list of elements.
@@ -59,6 +60,12 @@ request(refUrl, (error, response, html) => {
5960
}
6061
const $ = cheerio.load(html);
6162
const elements = extractElements($);
63+
if (elements.length !== expectedElCount) {
64+
throw new Error(
65+
'Unexpected number of elements extracted from ' + refUrl +
66+
' Check the output and edit expectedElCount if this is intended.'
67+
);
68+
}
6269
const out = elements.join('\n');
6370

6471
fs.writeFileSync(dataPath, out);

0 commit comments

Comments
 (0)