fix: reunpack the contents of a modified tarball dep

close #2747
PR #2759
This commit is contained in:
Zoltan Kochan
2020-08-09 23:34:30 +03:00
committed by GitHub
parent 400f419765
commit 9b90591e47
4 changed files with 19 additions and 9 deletions

View File

@@ -0,0 +1,5 @@
---
"supi": patch
---
The contents of a modified local tarball dependency should be reunpacked on install.

View File

@@ -77,6 +77,9 @@
},
{
"path": "../read-projects-context"
},
{
"path": "../../privatePackages/test-fixtures"
}
]
}

View File

@@ -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
}

View File

@@ -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