MCPcopy
hub / github.com/vitejs/vite / getLockfileHash

Function getLockfileHash

packages/vite/src/node/optimizer/index.ts:1329–1351  ·  view source on GitHub ↗
(environment: Environment)

Source from the content-addressed store, hash-verified

1327}
1328
1329function getLockfileHash(environment: Environment): string {
1330 const lockfilePath = lookupFile(environment.config.root, lockfilePaths)
1331 let content = lockfilePath ? fs.readFileSync(lockfilePath, 'utf-8') : ''
1332 if (lockfilePath) {
1333 const normalizedLockfilePath = lockfilePath.replaceAll('\\', '/')
1334 const lockfileFormat = lockfileFormats.find((f) =>
1335 normalizedLockfilePath.endsWith(f.path),
1336 )!
1337 if (lockfileFormat.checkPatchesDir) {
1338 // Default of https://github.com/ds300/patch-package
1339 const baseDir = lockfilePath.slice(0, -lockfileFormat.path.length)
1340 const fullPath = path.join(
1341 baseDir,
1342 lockfileFormat.checkPatchesDir as string,
1343 )
1344 const stat = tryStatSync(fullPath)
1345 if (stat?.isDirectory()) {
1346 content += stat.mtimeMs.toString()
1347 }
1348 }
1349 }
1350 return getHash(content)
1351}
1352
1353function getDepHash(environment: Environment): {
1354 lockfileHash: string

Callers 2

getDepHashFunction · 0.85

Calls 3

lookupFileFunction · 0.90
tryStatSyncFunction · 0.90
getHashFunction · 0.90

Tested by

no test coverage detected