MCPcopy Create free account
hub / github.com/Effect-TS/effect / computeJSDocInputHash

Function computeJSDocInputHash

packages/tools/jsdocs/src/Jsdocs.ts:1882–1932  ·  view source on GitHub ↗
(options: ExtractJSDocsOptions)

Source from the content-addressed store, hash-verified

1880 * @since 4.0.0
1881 */
1882export function computeJSDocInputHash(options: ExtractJSDocsOptions): string {
1883 const cwd = path.resolve(options.cwd ?? process.cwd())
1884 const hash = crypto.createHash("sha256")
1885 const files = new Set<string>()
1886
1887 hash.update(JSON.stringify({
1888 tsconfig: options.tsconfig,
1889 include: options.include,
1890 exclude: options.exclude ?? [],
1891 output: options.output
1892 }))
1893
1894 addInputFile(files, path.join(cwd, "jsdocs.config.json"))
1895 addInputFile(files, path.resolve(cwd, options.tsconfig))
1896
1897 for (
1898 const filename of globSync([...options.include], {
1899 cwd,
1900 absolute: true,
1901 nodir: true,
1902 ignore: ["**/node_modules/**"]
1903 })
1904 ) {
1905 addInputFile(files, filename)
1906 }
1907
1908 for (
1909 const filename of globSync([
1910 "package.json",
1911 "packages/**/package.json",
1912 "tsconfig*.json",
1913 "packages/**/tsconfig*.json"
1914 ], {
1915 cwd,
1916 absolute: true,
1917 nodir: true,
1918 ignore: ["**/node_modules/**"]
1919 })
1920 ) {
1921 addInputFile(files, filename)
1922 }
1923
1924 for (const filename of Array.from(files).sort()) {
1925 hash.update("\0")
1926 hash.update(normalizeFile(cwd, filename))
1927 hash.update("\0")
1928 hash.update(hashSource(fs.readFileSync(filename, "utf8")))
1929 }
1930
1931 return hash.digest("hex")
1932}
1933
1934function isIdentifierName(value: string): boolean {
1935 return /^[$A-Z_a-z][$\w]*$/.test(value)

Callers 3

jsdocs.test.tsFile · 0.90
bin.tsFile · 0.90
extractJSDocsSyncFunction · 0.85

Calls 6

addInputFileFunction · 0.85
normalizeFileFunction · 0.85
hashSourceFunction · 0.85
joinMethod · 0.80
digestMethod · 0.80
updateMethod · 0.45

Tested by

no test coverage detected