mirror of
https://github.com/pnpm/pnpm.git
synced 2026-05-05 06:28:47 -04:00
fix: forced install shoud relink packages in node_modules
This commit is contained in:
@@ -146,7 +146,7 @@ export default async (opts: HeadlessOptions) => {
|
||||
const filteredShrinkwrap = filterShrinkwrap(wantedShrinkwrap, filterOpts)
|
||||
|
||||
stageLogger.debug('importing_started')
|
||||
const depGraph = await shrinkwrapToDepGraph(filteredShrinkwrap, currentShrinkwrap, opts)
|
||||
const depGraph = await shrinkwrapToDepGraph(filteredShrinkwrap, opts.force ? null : currentShrinkwrap, opts)
|
||||
|
||||
statsLogger.debug({added: Object.keys(depGraph).length})
|
||||
|
||||
|
||||
@@ -233,6 +233,44 @@ test('available packages are used when node_modules is not clean', async (t) =>
|
||||
t.end()
|
||||
})
|
||||
|
||||
test('available packages are relinked during forced install', async (t) => {
|
||||
const projectDir = tempy.directory()
|
||||
t.comment(projectDir)
|
||||
|
||||
const destPackageJsonPath = path.join(projectDir, 'package.json')
|
||||
const destShrinkwrapYamlPath = path.join(projectDir, 'shrinkwrap.yaml')
|
||||
|
||||
const hasGlobDir = path.join(fixtures, 'has-glob')
|
||||
const hasGlobAndRimrafDir = path.join(fixtures, 'has-glob-and-rimraf')
|
||||
fse.copySync(path.join(hasGlobDir, 'package.json'), destPackageJsonPath)
|
||||
fse.copySync(path.join(hasGlobDir, 'shrinkwrap.yaml'), destShrinkwrapYamlPath)
|
||||
|
||||
await headless(await testDefaults({prefix: projectDir}))
|
||||
|
||||
fse.copySync(path.join(hasGlobAndRimrafDir, 'package.json'), destPackageJsonPath)
|
||||
fse.copySync(path.join(hasGlobAndRimrafDir, 'shrinkwrap.yaml'), destShrinkwrapYamlPath)
|
||||
|
||||
const reporter = sinon.spy()
|
||||
await headless(await testDefaults({prefix: projectDir, reporter, force: true}))
|
||||
|
||||
const project = assertProject(t, projectDir)
|
||||
await project.has('rimraf')
|
||||
await project.has('glob')
|
||||
|
||||
t.ok(reporter.calledWithMatch({
|
||||
level: 'debug',
|
||||
pkgId: 'localhost+4873/balanced-match/1.0.0',
|
||||
status: 'resolving_content',
|
||||
} as ProgressLog), 'does not resolve already available package')
|
||||
t.ok(reporter.calledWithMatch({
|
||||
level: 'debug',
|
||||
pkgId: 'localhost+4873/rimraf/2.6.2',
|
||||
status: 'resolving_content',
|
||||
} as ProgressLog), 'resolves rimraf')
|
||||
|
||||
t.end()
|
||||
})
|
||||
|
||||
test('fail when shrinkwrap.yaml is not up-to-date with package.json', async (t) => {
|
||||
const projectDir = tempy.directory()
|
||||
t.comment(projectDir)
|
||||
|
||||
Reference in New Issue
Block a user