-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathindex.ts
More file actions
39 lines (32 loc) · 1.19 KB
/
Copy pathindex.ts
File metadata and controls
39 lines (32 loc) · 1.19 KB
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
38
39
import { glob } from 'glob'
import { comparePublicApiToReadme } from './lib/comparePublicApiToReadme'
/**
* This script checks if README.md files in src/ are up to date with the public API. It compares exports from index.ts with blocks in README.md and prints missing exports and exports that should be removed (if they are no longer in public API).
*
* If everything is up to date, nothing is printed.
*/
const checkLayerDocs = async () => {
const files = await glob('src/**/README.md', {
ignore: ['**/node_modules/**', '**/build/**'],
})
files.forEach(async (pathToReadme) => {
const { exportsToAdd, exportsToRemove } =
await comparePublicApiToReadme(pathToReadme)
const isExportsNotEmpty = exportsToAdd.length > 0
const isMissingPublicAPIExportsNotEmpty =
exportsToRemove.length > 0
if (isExportsNotEmpty || isMissingPublicAPIExportsNotEmpty) {
console.log(`\n${pathToReadme}`)
}
if (isExportsNotEmpty) {
console.log(`Following items missing in README:`, exportsToAdd)
}
if (isMissingPublicAPIExportsNotEmpty) {
console.log(
`Remove following items from README:`,
exportsToRemove
)
}
})
}
checkLayerDocs()