mirror of
https://github.com/pnpm/pnpm.git
synced 2026-01-29 09:12:16 -05:00
fix(patch): the hash of the patch file should be the same on both Windows and POSIX (#4969)
close #4961
This commit is contained in:
6
.changeset/soft-seals-shop.md
Normal file
6
.changeset/soft-seals-shop.md
Normal file
@@ -0,0 +1,6 @@
|
||||
---
|
||||
"@pnpm/crypto.base32-hash": patch
|
||||
"pnpm": patch
|
||||
---
|
||||
|
||||
The hash of the patch file should be the same on both Windows and POSIX [#4961](https://github.com/pnpm/pnpm/issues/4961).
|
||||
@@ -34,7 +34,8 @@
|
||||
"rfc4648": "^1.5.1"
|
||||
},
|
||||
"devDependencies": {
|
||||
"@pnpm/crypto.base32-hash": "workspace:*"
|
||||
"@pnpm/crypto.base32-hash": "workspace:*",
|
||||
"@pnpm/prepare": "workspace:*"
|
||||
},
|
||||
"funding": "https://opencollective.com/pnpm",
|
||||
"exports": {
|
||||
|
||||
@@ -7,5 +7,6 @@ export function createBase32Hash (str: string): string {
|
||||
}
|
||||
|
||||
export async function createBase32HashFromFile (file: string): Promise<string> {
|
||||
return createBase32Hash(await fs.promises.readFile(file, 'utf8'))
|
||||
const content = await fs.promises.readFile(file, 'utf8')
|
||||
return createBase32Hash(content.split('\r\n').join('\n'))
|
||||
}
|
||||
|
||||
@@ -1,6 +1,15 @@
|
||||
/// <reference path="../../../typings/index.d.ts"/>
|
||||
import { createBase32Hash } from '@pnpm/crypto.base32-hash'
|
||||
import fs from 'fs'
|
||||
import { createBase32Hash, createBase32HashFromFile } from '@pnpm/crypto.base32-hash'
|
||||
import { tempDir } from '@pnpm/prepare'
|
||||
|
||||
test('createBase32Hash()', () => {
|
||||
expect(createBase32Hash('AAA')).toEqual('4h5p7m7gcttmf65hikljmi4gw4')
|
||||
})
|
||||
|
||||
test('createBase32HashFromFile normalizes line endings before calculating the hash', async () => {
|
||||
tempDir()
|
||||
fs.writeFileSync('win-eol.txt', 'a\r\nb\r\nc')
|
||||
fs.writeFileSync('posix-eol.txt', 'a\nb\r\nc')
|
||||
expect(await createBase32HashFromFile('win-eol.txt')).toEqual(await createBase32HashFromFile('posix-eol.txt'))
|
||||
})
|
||||
|
||||
@@ -8,5 +8,9 @@
|
||||
"src/**/*.ts",
|
||||
"../../typings/**/*.d.ts"
|
||||
],
|
||||
"references": []
|
||||
"references": [
|
||||
{
|
||||
"path": "../../privatePackages/prepare"
|
||||
}
|
||||
]
|
||||
}
|
||||
|
||||
2
pnpm-lock.yaml
generated
2
pnpm-lock.yaml
generated
@@ -613,11 +613,13 @@ importers:
|
||||
packages/crypto.base32-hash:
|
||||
specifiers:
|
||||
'@pnpm/crypto.base32-hash': workspace:*
|
||||
'@pnpm/prepare': workspace:*
|
||||
rfc4648: ^1.5.1
|
||||
dependencies:
|
||||
rfc4648: 1.5.2
|
||||
devDependencies:
|
||||
'@pnpm/crypto.base32-hash': 'link:'
|
||||
'@pnpm/prepare': link:../../privatePackages/prepare
|
||||
|
||||
packages/default-reporter:
|
||||
specifiers:
|
||||
|
||||
Reference in New Issue
Block a user