mirror of
https://github.com/pnpm/pnpm.git
synced 2025-12-23 23:29:17 -05:00
fix: sort patchedDependencies consistently in lockfiles (#6208)
This commit is contained in:
6
.changeset/loud-geese-obey.md
Normal file
6
.changeset/loud-geese-obey.md
Normal file
@@ -0,0 +1,6 @@
|
||||
---
|
||||
"@pnpm/lockfile-file": patch
|
||||
"pnpm": patch
|
||||
---
|
||||
|
||||
`patchedDependencies` are now sorted consistently in the lockfile [#6208](https://github.com/pnpm/pnpm/pull/6208).
|
||||
@@ -77,9 +77,9 @@ export function sortLockfileKeys (lockfile: LockfileFile) {
|
||||
})
|
||||
}
|
||||
}
|
||||
for (const key of ['specifiers', 'dependencies', 'devDependencies', 'optionalDependencies', 'time'] as const) {
|
||||
for (const key of ['specifiers', 'dependencies', 'devDependencies', 'optionalDependencies', 'time', 'patchedDependencies'] as const) {
|
||||
if (!lockfile[key]) continue
|
||||
lockfile[key] = sortKeys(lockfile[key]!)
|
||||
lockfile[key] = sortKeys<any>(lockfile[key]) // eslint-disable-line @typescript-eslint/no-explicit-any
|
||||
}
|
||||
return sortKeys(lockfile, { compare: compareRootKeys })
|
||||
}
|
||||
|
||||
@@ -26,6 +26,11 @@ test('sorts keys alphabetically', () => {
|
||||
},
|
||||
},
|
||||
},
|
||||
patchedDependencies: {
|
||||
zzz: { path: 'foo', hash: 'bar' },
|
||||
bar: { path: 'foo', hash: 'bar' },
|
||||
aaa: { path: 'foo', hash: 'bar' },
|
||||
},
|
||||
})
|
||||
|
||||
expect(normalizedLockfile).toStrictEqual({
|
||||
@@ -52,9 +57,15 @@ test('sorts keys alphabetically', () => {
|
||||
},
|
||||
},
|
||||
},
|
||||
patchedDependencies: {
|
||||
aaa: { path: 'foo', hash: 'bar' },
|
||||
bar: { path: 'foo', hash: 'bar' },
|
||||
zzz: { path: 'foo', hash: 'bar' },
|
||||
},
|
||||
})
|
||||
expect(Object.keys(normalizedLockfile.importers?.foo.dependencies ?? {})).toStrictEqual(['aaa', 'bar', 'zzz'])
|
||||
expect(Object.keys(normalizedLockfile.importers?.foo.specifiers ?? {})).toStrictEqual(['aaa', 'bar', 'zzz'])
|
||||
expect(Object.keys(normalizedLockfile.patchedDependencies ?? {})).toStrictEqual(['aaa', 'bar', 'zzz'])
|
||||
})
|
||||
|
||||
test('sorting does not care about locale (e.g. Czech has "ch" as a single character after "h")', () => {
|
||||
|
||||
Reference in New Issue
Block a user