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

Function computeJSDocInputHash

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

Source from the content-addressed store, hash-verified

1931 * @since 4.0.0
1932 */
1933export function computeJSDocInputHash(options: ExtractJSDocsOptions): string {
1934 const cwd = path.resolve(options.cwd ?? process.cwd())
1935 const hash = crypto.createHash("sha256")
1936 const files = new Set<string>()
1937
1938 hash.update(JSON.stringify({
1939 tsconfig: options.tsconfig,
1940 include: options.include,
1941 exclude: options.exclude ?? [],
1942 output: options.output
1943 }))
1944
1945 addInputFile(files, path.join(cwd, "jsdocs.config.json"))
1946 addInputFile(files, path.resolve(cwd, options.tsconfig))
1947
1948 for (
1949 const filename of globSync([...options.include], {
1950 cwd,
1951 absolute: true,
1952 nodir: true,
1953 ignore: ["**/node_modules/**"]
1954 })
1955 ) {
1956 addInputFile(files, filename)
1957 }
1958
1959 for (
1960 const filename of globSync([
1961 "package.json",
1962 "packages/**/package.json",
1963 "tsconfig*.json",
1964 "packages/**/tsconfig*.json"
1965 ], {
1966 cwd,
1967 absolute: true,
1968 nodir: true,
1969 ignore: ["**/node_modules/**"]
1970 })
1971 ) {
1972 addInputFile(files, filename)
1973 }
1974
1975 for (const filename of Array.from(files).sort()) {
1976 hash.update("\0")
1977 hash.update(normalizeFile(cwd, filename))
1978 hash.update("\0")
1979 hash.update(hashSource(fs.readFileSync(filename, "utf8")))
1980 }
1981
1982 return hash.digest("hex")
1983}
1984
1985function isIdentifierName(value: string): boolean {
1986 return /^[$A-Z_a-z][$\w]*$/.test(value)

Callers 3

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

Calls 8

addInputFileFunction · 0.85
normalizeFileFunction · 0.85
hashSourceFunction · 0.85
resolveMethod · 0.80
fromMethod · 0.80
updateMethod · 0.65
joinMethod · 0.45
digestMethod · 0.45

Tested by

no test coverage detected