mirror of
https://github.com/pnpm/pnpm.git
synced 2026-03-30 04:52:04 -04:00
fix: modules directory compatibility check
Always check the layout version first.
This commit is contained in:
5
.changeset/twelve-ladybugs-float.md
Normal file
5
.changeset/twelve-ladybugs-float.md
Normal file
@@ -0,0 +1,5 @@
|
||||
---
|
||||
"@pnpm/get-context": patch
|
||||
---
|
||||
|
||||
When checking compatibility of the existing modules directory, start with the layout version. Otherwise, it may happen that some of the fields were renamed and other checks will fail.
|
||||
@@ -13,11 +13,16 @@ export default function checkCompatibility (
|
||||
virtualStoreDir: string,
|
||||
}
|
||||
) {
|
||||
if (!modules.layoutVersion || modules.layoutVersion !== LAYOUT_VERSION) {
|
||||
throw new ModulesBreakingChangeError({
|
||||
modulesPath: opts.modulesDir,
|
||||
})
|
||||
}
|
||||
// Important: comparing paths with path.relative()
|
||||
// is the only way to compare paths correctly on Windows
|
||||
// as of Node.js 4-9
|
||||
// See related issue: https://github.com/pnpm/pnpm/issues/996
|
||||
if (path.relative(modules.storeDir, opts.storeDir) !== '') {
|
||||
if (!modules.storeDir || path.relative(modules.storeDir, opts.storeDir) !== '') {
|
||||
throw new UnexpectedStoreError({
|
||||
actualStorePath: opts.storeDir,
|
||||
expectedStorePath: modules.storeDir,
|
||||
@@ -31,9 +36,4 @@ export default function checkCompatibility (
|
||||
modulesDir: opts.modulesDir,
|
||||
})
|
||||
}
|
||||
if (!modules.layoutVersion || modules.layoutVersion !== LAYOUT_VERSION) {
|
||||
throw new ModulesBreakingChangeError({
|
||||
modulesPath: opts.modulesDir,
|
||||
})
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user