mirror of
https://github.com/nodejs/node.git
synced 2024-11-21 10:59:27 +00:00
3ce4cef4e6
PR-URL: https://github.com/nodejs/node/pull/45889 Reviewed-By: Anna Henningsen <anna@addaleax.net> Reviewed-By: Yagiz Nizipli <yagiz@nizipli.com>
43 lines
1.1 KiB
JavaScript
Executable File
43 lines
1.1 KiB
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));
|
|
} else if (toc && line.startsWith('<b><a')) {
|
|
result.push(line.slice(line.indexOf('>', 3) + 1, -'</a></b><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(`NODE_RELEASED_VERSIONS=${result.join(',')}`);
|