diff options
| author | ST-DDT <[email protected]> | 2023-02-01 22:33:15 +0100 |
|---|---|---|
| committer | GitHub <[email protected]> | 2023-02-01 22:33:15 +0100 |
| commit | 9c3618d66550b7a72cade402b035ecdbcb485625 (patch) | |
| tree | 0f6792026c965c745f6763b9ba1b14a3d26f828e /scripts/diff.ts | |
| parent | de7ed2e3b823131345995da6ec52c2b0c40c8d6e (diff) | |
| download | faker-9c3618d66550b7a72cade402b035ecdbcb485625.tar.xz faker-9c3618d66550b7a72cade402b035ecdbcb485625.zip | |
infra(docs): add docs diff script (#1755)
Diffstat (limited to 'scripts/diff.ts')
| -rw-r--r-- | scripts/diff.ts | 30 |
1 files changed, 30 insertions, 0 deletions
diff --git a/scripts/diff.ts b/scripts/diff.ts new file mode 100644 index 00000000..09a07046 --- /dev/null +++ b/scripts/diff.ts @@ -0,0 +1,30 @@ +import { existsSync } from 'node:fs'; +import { argv } from 'node:process'; +import { diff } from './apidoc/diff'; +import { pathDocsDiffIndexFile } from './apidoc/utils'; + +const [target, source] = argv.slice(2); + +if (!source && !existsSync(pathDocsDiffIndexFile)) { + throw new Error( + `Unable to find local diff index file at: ${pathDocsDiffIndexFile}\n + You can run \`pnpm run generate:api-docs\` to generate it.` + ); +} + +diff(target, source) + .then((delta) => { + if (Object.keys(delta).length === 0) { + console.log('No documentation changes detected'); + return; + } + + console.log('Documentation changes detected:'); + for (const [module, methods] of Object.entries(delta)) { + console.log(`- ${module}`); + for (const method of methods) { + console.log(` - ${method}`); + } + } + }) + .catch(console.error); |
