-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathverify-docs.js
37 lines (30 loc) · 928 Bytes
/
verify-docs.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
const fs = require("fs");
const path = require("path");
// before any publication, this script checks
// if all the most important files are in sync.
const filePaths = [
"./doc-for-c2c-widget/docs/_usage.mdx",
"./embed-script/README.md",
"./README.md",
];
function verifyFiles() {
const contents = filePaths.map((filePath) => {
try {
return fs.readFileSync(path.join(__dirname, filePath), "utf8");
} catch (error) {
console.error(`Error reading file ${filePath}:`, error.message);
process.exit(1);
}
});
const firstContent = contents[0];
const mismatchedFiles = filePaths.filter(
(filePath, index) => contents[index] !== firstContent
);
if (mismatchedFiles.length > 0) {
console.error("Documentation files are not in sync:");
console.error(mismatchedFiles.join("\n"));
process.exit(1);
}
console.log("Documentation files are in sync");
}
verifyFiles();