fix(headless): use headless install on monorepo with dir deps

This commit is contained in:
Zoltan Kochan
2018-11-20 01:22:35 +02:00
parent 59c775e4a2
commit 67abbf19cd
2 changed files with 47 additions and 1 deletions

View File

@@ -338,7 +338,7 @@ async function linkedPackagesAreUpToDate (
for (const depName of depNames) {
if (!pkgDeps[depName]) continue
const isLinked = importerDeps[depName].startsWith('link:')
if (isLinked && pkgDeps[depName].startsWith('link:')) continue
if (isLinked && (pkgDeps[depName].startsWith('link:') || pkgDeps[depName].startsWith('file:'))) continue
const dir = isLinked
? path.join(prefix, importerDeps[depName].substr(5))
: (localPackages && localPackages[depName] && localPackages[depName] && localPackages[depName][importerDeps[depName]] && localPackages[depName][importerDeps[depName]].directory)

View File

@@ -2,6 +2,7 @@ import assertProject from '@pnpm/assert-project'
import { preparePackages } from '@pnpm/prepare'
import path = require('path')
import readPkg = require('read-pkg')
import sinon = require('sinon')
import { install, installPkgs } from 'supi'
import tape = require('tape')
import promisifyTape from 'tape-promise'
@@ -158,3 +159,48 @@ test('adding a new dev dependency to project that uses a shared shrinkwrap', asy
t.deepEqual(pkg.dependencies, { 'is-positive': '1.0.0' }, 'prod deps unchanged in package.json')
t.deepEqual(pkg.devDependencies, { 'is-negative': '^1.0.0' }, 'dev deps have a new dependency in package.json')
})
test('headless install is used when package link to another package in the workspace', async (t) => {
const projects = preparePackages(t, [
{
name: 'project-1',
version: '1.0.0',
dependencies: {
'is-positive': '1.0.0',
'project-2': 'file:../project-2',
},
},
{
name: 'project-2',
version: '1.0.0',
dependencies: {
'is-negative': '1.0.0',
},
},
])
const importers = [
{
prefix: path.resolve('project-1'),
},
{
prefix: path.resolve('project-2'),
},
]
await install(await testDefaults({ importers, shrinkwrapOnly: true }))
const reporter = sinon.spy()
await install(await testDefaults({ importers: importers.slice(0, 1), reporter }))
t.ok(reporter.calledWithMatch({
level: 'info',
message: 'Performing headless installation',
name: 'pnpm',
}), 'start of headless installation logged')
await projects['project-1'].has('is-positive')
await projects['project-1'].has('project-2')
await projects['project-2'].hasNot('is-negative')
})