mirror of
https://github.com/pnpm/pnpm.git
synced 2026-04-10 18:18:56 -04:00
fix: reunpack the contents of a modified tarball dep
close #2747 PR #2759
This commit is contained in:
5
.changeset/gorgeous-laws-rush.md
Normal file
5
.changeset/gorgeous-laws-rush.md
Normal file
@@ -0,0 +1,5 @@
|
||||
---
|
||||
"supi": patch
|
||||
---
|
||||
|
||||
The contents of a modified local tarball dependency should be reunpacked on install.
|
||||
@@ -77,6 +77,9 @@
|
||||
},
|
||||
{
|
||||
"path": "../read-projects-context"
|
||||
},
|
||||
{
|
||||
"path": "../../privatePackages/test-fixtures"
|
||||
}
|
||||
]
|
||||
}
|
||||
|
||||
@@ -194,7 +194,6 @@ export default async function linkPackages (
|
||||
force: opts.force,
|
||||
lockfileDir: opts.lockfileDir,
|
||||
optional: opts.include.optionalDependencies,
|
||||
registries: opts.registries,
|
||||
sideEffectsCacheRead: opts.sideEffectsCacheRead,
|
||||
skipped: opts.skipped,
|
||||
storeController: opts.storeController,
|
||||
@@ -366,7 +365,6 @@ async function linkNewPackages (
|
||||
dryRun: boolean,
|
||||
force: boolean,
|
||||
optional: boolean,
|
||||
registries: Registries,
|
||||
lockfileDir: string,
|
||||
sideEffectsCacheRead: boolean,
|
||||
skipped: Set<string>,
|
||||
@@ -385,7 +383,7 @@ async function linkNewPackages (
|
||||
.filter((depPath) => depGraph[depPath])
|
||||
)
|
||||
} else {
|
||||
newDepPathsSet = await selectNewFromWantedDeps(wantedRelDepPaths, currentLockfile, depGraph, opts)
|
||||
newDepPathsSet = await selectNewFromWantedDeps(wantedRelDepPaths, currentLockfile, depGraph)
|
||||
}
|
||||
|
||||
statsLogger.debug({
|
||||
@@ -440,19 +438,20 @@ async function linkNewPackages (
|
||||
async function selectNewFromWantedDeps (
|
||||
wantedRelDepPaths: string[],
|
||||
currentLockfile: Lockfile,
|
||||
depGraph: DependenciesGraph,
|
||||
opts: {
|
||||
registries: Registries,
|
||||
}
|
||||
depGraph: DependenciesGraph
|
||||
) {
|
||||
const newDeps = new Set<string>()
|
||||
const prevRelDepPaths = new Set(R.keys(currentLockfile.packages))
|
||||
const prevDeps = currentLockfile.packages ?? {}
|
||||
await Promise.all(
|
||||
wantedRelDepPaths.map(
|
||||
async (depPath: string) => {
|
||||
const depNode = depGraph[depPath]
|
||||
if (!depNode) return
|
||||
if (prevRelDepPaths.has(depPath)) {
|
||||
const prevDep = prevDeps[depPath]
|
||||
if (
|
||||
prevDep &&
|
||||
depNode.resolution['integrity'] === prevDep.resolution['integrity']
|
||||
) {
|
||||
if (await fs.exists(depNode.dir)) {
|
||||
return
|
||||
}
|
||||
|
||||
@@ -178,6 +178,9 @@ test('update tarball local package when its integrity changes', async (t) => {
|
||||
|
||||
const lockfile2 = await project.readLockfile()
|
||||
t.equal(lockfile2.packages['file:../tar.tgz'].dependencies!['is-positive'], '2.0.0', 'the local tarball dep has been updated')
|
||||
|
||||
const manifestOfTarballDep = await import(path.resolve('node_modules/tar-pkg-with-dep/package.json'))
|
||||
t.equal(manifestOfTarballDep.dependencies['is-positive'], '^2.0.0', 'the tarball dependency content was reunpacked')
|
||||
})
|
||||
|
||||
// Covers https://github.com/pnpm/pnpm/issues/1878
|
||||
|
||||
Reference in New Issue
Block a user