File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change 1- import { createHash } from 'node:crypto' ;
1+ import { hash } from 'node:crypto' ;
22import { isAbsolute } from 'node:path' ;
33import stableStringify from 'fast-json-stable-stringify' ;
44import { fmtCacheVersion } from './cacheStore.ts' ;
@@ -12,8 +12,7 @@ type CacheKeyResolver = (filePath: string) => string | undefined;
1212type OptionsHasher = ( options : ResolvedFmtOptions ) => string | undefined ;
1313type PluginFingerprints = ReadonlyMap < string , string > ;
1414
15- const sha256 = ( content : string | Uint8Array ) : string =>
16- createHash ( 'sha256' ) . update ( content ) . digest ( 'hex' ) ;
15+ const sha256 = ( content : string | Uint8Array ) : string => hash ( 'sha256' , content , 'hex' ) ;
1716
1817/** Identifies formatter behavior shared by all cache entries in this process. */
1918const cacheNamespace : string = JSON . stringify ( [ fmtCacheVersion , RSTACK_VERSION , PRETTIER_VERSION ] ) ;
Original file line number Diff line number Diff line change 11// Derived from @prettier /cli, see THIRD_PARTY_NOTICES.md
22
3- import { createHash } from 'node:crypto' ;
3+ import { hash } from 'node:crypto' ;
44import { readFileSync , writeFileSync } from 'node:fs' ;
55import type { FmtCacheEntry } from './cacheStore.ts' ;
66import type { FmtFileCache , FmtFileRequest , FmtWorkerResult } from './types.ts' ;
@@ -11,8 +11,7 @@ interface FormatFileTask {
1111 cache ?: FmtFileCache ;
1212}
1313
14- const hashContent = ( content : string | Uint8Array ) : string =>
15- createHash ( 'sha256' ) . update ( content ) . digest ( 'hex' ) ;
14+ const hashContent = ( content : string | Uint8Array ) : string => hash ( 'sha256' , content , 'hex' ) ;
1615
1716/**
1817 * Use synchronous direct I/O inside the dedicated worker to avoid libuv
You can’t perform that action at this time.
0 commit comments