node/tools/lint-md/list-released-versions-from-changelogs.mjs
Rich Trott 8d83c47029 tools: re-implement lint-md without unified-args
`unified-args` ignores settings in the preset, expecting them to be in
remarkrc files or passed on the command line instead. Realizing that
we always send the same configuration options via the command-line
anyway, this removes `unified-args`. This means the preset settings are
now respected and it removes nearly 30000 lines of code in the resulting
rollup file.

I wasn't sure I was going to want to keep rollup so I started
re-implementing this without it, but ended up putting a minimal rollup
back as it still saves about 90000 lines of code vs. checking in
`node_modules`.

PR-URL: https://github.com/nodejs/node/pull/40180
Reviewed-By: Antoine du Hamel <duhamelantoine1995@gmail.com>
Reviewed-By: James M Snell <jasnell@gmail.com>
2021-09-25 03:51:52 +00:00

41 lines
1009 B
JavaScript
Executable File

#!/usr/bin/env node
import fs from 'node:fs';
import { createInterface } from 'node:readline';
const dataFolder = new URL('../../doc/changelogs/', import.meta.url);
const result = [];
async function getVersionsFromFile(file) {
const input = fs.createReadStream(file);
let toc = false;
for await (const line of createInterface({
input,
crlfDelay: Infinity,
})) {
if (toc === false && line === '<table>') {
toc = true;
} else if (toc && line[0] !== '<') {
input.close();
return;
} else if (toc && line.startsWith('<a')) {
result.push(line.slice(line.indexOf('>') + 1, -'</a><br/>'.length));
}
}
}
const filesToCheck = [];
const dir = await fs.promises.opendir(dataFolder);
for await (const dirent of dir) {
if (dirent.isFile()) {
filesToCheck.push(
getVersionsFromFile(new URL(`./${dirent.name}`, dataFolder))
);
}
}
await Promise.all(filesToCheck);
console.log(`::set-output name=NODE_RELEASED_VERSIONS::${result.join(',')}`);