-
Notifications
You must be signed in to change notification settings - Fork 29.7k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
tools: check version number in YAML comments from changelogs
PR-URL: #37599 Refs: nodejs/remark-preset-lint-node#172 Reviewed-By: Darshan Sen <raisinten@gmail.com> Reviewed-By: Rich Trott <rtrott@gmail.com> Reviewed-By: James M Snell <jasnell@gmail.com>
- Loading branch information
Showing
2 changed files
with
46 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
40 changes: 40 additions & 0 deletions
40
tools/node-lint-md-cli-rollup/src/list-released-versions-from-changelogs.mjs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,40 @@ | ||
#!/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(',')}`); |