mirror of
https://github.com/pnpm/pnpm.git
synced 2026-03-29 20:41:47 -04:00
@@ -34,6 +34,7 @@
|
||||
"common-tags": "1.4.0",
|
||||
"cross-spawn": "^5.0.0",
|
||||
"delocalize-dependencies": "0.1.0",
|
||||
"dirsum": "0.1.1",
|
||||
"execa": "0.6.0",
|
||||
"exists-file": "3.0.0",
|
||||
"find-up": "2.1.0",
|
||||
|
||||
10
src/fs/dirsum.ts
Normal file
10
src/fs/dirsum.ts
Normal file
@@ -0,0 +1,10 @@
|
||||
import dirsum = require('dirsum')
|
||||
|
||||
export default function (dirpath: string): Promise<string> {
|
||||
return new Promise((resolve, reject) => {
|
||||
dirsum.digest(dirpath, 'sha1', (err: Error, hashes: {hash: string}) => {
|
||||
if (err) return reject(err)
|
||||
resolve(hashes.hash)
|
||||
})
|
||||
})
|
||||
}
|
||||
@@ -16,6 +16,7 @@ import {InstallContext} from '../api/install'
|
||||
import fetchResolution from './fetchResolution'
|
||||
import logStatus from '../logging/logInstallStatus'
|
||||
import {PackageMeta} from '../resolve/utils/loadPackageMeta'
|
||||
import dirsum from '../fs/dirsum'
|
||||
|
||||
export type FetchOptions = {
|
||||
keypath?: string[],
|
||||
@@ -198,7 +199,21 @@ function fetchToStoreCached (opts: FetchToStoreOptions): Promise<void> {
|
||||
// fs.rename(oldPath, newPath) is an atomic operation, so we do it at the
|
||||
// end
|
||||
await fs.rename(targetStage, target)
|
||||
|
||||
createShasum(target)
|
||||
}
|
||||
const pkg = await requireJson(path.join(target, 'package.json'))
|
||||
})
|
||||
}
|
||||
|
||||
async function createShasum(dirPath: string) {
|
||||
try {
|
||||
const shasum = await dirsum(dirPath)
|
||||
await fs.writeFile(`${dirPath}_shasum`, shasum, 'utf8')
|
||||
} catch (err) {
|
||||
logger.error({
|
||||
message: `Failed to calculate shasum for ${dirPath}`,
|
||||
err,
|
||||
})
|
||||
}
|
||||
}
|
||||
|
||||
5
typings/local.d.ts
vendored
5
typings/local.d.ts
vendored
@@ -232,3 +232,8 @@ declare module 'p-limit' {
|
||||
const anything: any;
|
||||
export = anything;
|
||||
}
|
||||
|
||||
declare module 'dirsum' {
|
||||
const anything: any;
|
||||
export = anything;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user