Skip to content

Commit

Permalink
Check to verify that there are not missing md files (#5553)
Browse files Browse the repository at this point in the history
* Github check to verify that there are not missing md files

* linebreaks
  • Loading branch information
jrood authored Jan 6, 2025
1 parent e7eed0b commit b7624d0
Show file tree
Hide file tree
Showing 3 changed files with 25 additions and 2 deletions.
22 changes: 22 additions & 0 deletions .github/scripts/validate-content-tree.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
const { readdirSync } = require('node:fs');

let exitCode = 0;

const next = ['concepts', 'terms'];

function checkPath(path, i) {
for (const entry of readdirSync(path)) {
const entryDir = readdirSync(`${path}/${entry}`);
if (!entryDir.includes(`${entry}.md`)) {
console.error(`\n${path}/${entry} should contain a ${entry}.md file\n`);
exitCode = 1;
}
if (i < 2 && entryDir.includes(next[i])) {
checkPath(`${path}/${entry}/${next[i]}`, i + 1);
}
}
}

checkPath('content', 0);

process.exit(exitCode);
2 changes: 1 addition & 1 deletion .github/workflows/push.yml
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ jobs:
strategy:
fail-fast: false
matrix:
command: ["compile", "format:verify", "lint:js", "lint:md", "test"]
command: ["compile", "format:verify", "lint:js", "lint:md", "test", "validate-content-tree"]

on:
push:
Expand Down
3 changes: 2 additions & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,8 @@
"lint:md": "markdownlint \"./content/**/*.md\"",
"lint": "yarn lint:md && yarn lint:js",
"test": "jest",
"prepare": "husky install"
"prepare": "husky install",
"validate-content-tree": "node .github/scripts/validate-content-tree.js"
},
"license": "UNLICENSED",
"version": "1.0.0"
Expand Down

0 comments on commit b7624d0

Please sign in to comment.