mirror of
https://github.com/nodejs/node.git
synced 2026-10-28 18:25:13 +08:00
tools: check version number in YAML comments from changelogs
PR-URL: https://github.com/nodejs/node/pull/37599 Refs: https://github.com/nodejs/remark-preset-lint-node/pull/172 Reviewed-By: Darshan Sen <raisinten@gmail.com> Reviewed-By: Rich Trott <rtrott@gmail.com> Reviewed-By: James M Snell <jasnell@gmail.com>
This commit is contained in:
1 parent
2e1e74e9f8
commit
8de1e19cab
2 files changed
+46
No files matched your search
@@ -50,10 +50,16 @@ jobs:
|
||||
node-version: ${{ env.NODE_VERSION }}
|
||||
- name: Environment Information
|
||||
run: npx envinfo
|
||||
- name: Get release version numbers
|
||||
id: get-released-versions
|
||||
run: ./tools/node-lint-md-cli-rollup/src/list-released-versions-from-changelogs.mjs
|
||||
- name: Lint docs
|
||||
run: |
|
||||
echo "::add-matcher::.github/workflows/remark-lint-problem-matcher.json"
|
||||
NODE=$(command -v node) make lint-md
|
||||
env:
|
||||
NODE_RELEASED_VERSIONS: ${{ steps.get-released-versions.outputs.NODE_RELEASED_VERSIONS }}
|
||||
|
||||
lint-js:
|
||||
if: github.event.pull_request.draft == false
|
||||
runs-on: ubuntu-latest
|
||||
|
||||
+40
@@ -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(',')}`);
|
||||
Reference in new issue
Block a user