Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions manifests/preferred.json
Original file line number Diff line number Diff line change
Expand Up @@ -171,7 +171,7 @@
{
"type": "documented",
"moduleName": "ezspawn",
"docPath": "process-exec",
"docPath": "ez-spawn",
"category": "preferred"
},
{
Expand Down Expand Up @@ -243,7 +243,7 @@
{
"type": "documented",
"moduleName": "grapheme-splitter",
"docPath": "grapheme",
"docPath": "graphemer",
"category": "preferred"
},
{
Expand Down
21 changes: 20 additions & 1 deletion scripts/check-manifest-problems.js
Original file line number Diff line number Diff line change
@@ -1,9 +1,10 @@
import {readdir, readFile} from 'node:fs/promises';
import {readdir, readFile, access} from 'node:fs/promises';
import {fileURLToPath} from 'node:url';
import * as path from 'node:path';

const scriptDir = fileURLToPath(new URL('.', import.meta.url));
const manifestsDir = path.resolve(scriptDir, '../manifests');
const docsDir = path.resolve(scriptDir, '../docs/modules');
const seenModules = new Set();

async function checkManifestForDuplicates(name, manifest) {
Expand Down Expand Up @@ -60,6 +61,24 @@ export async function checkManifestsForProblems() {

await checkManifestForDuplicates(manifestName, manifest);
checkManifestIsSorted(manifestName, manifest);
await checkDocPathsExist(manifestName, manifest);
}
console.log('OK');
}

async function checkDocPathsExist(name, manifest) {
for (const mod of manifest.moduleReplacements) {
if (!mod.docPath) {
continue;
}

const docFile = path.join(docsDir, `${mod.docPath}.md`);
try {
await access(docFile);
} catch {
throw new Error(
`Module ${mod.moduleName} in ${name} has docPath "${mod.docPath}" but ${mod.docPath}.md does not exist in docs/modules/`
);
}
}
}