mirror of
https://github.com/pnpm/pnpm.git
synced 2026-04-10 18:18:56 -04:00
5
.changeset/silly-moles-sing.md
Normal file
5
.changeset/silly-moles-sing.md
Normal file
@@ -0,0 +1,5 @@
|
||||
---
|
||||
"@pnpm/plugin-commands-installation": patch
|
||||
---
|
||||
|
||||
Linking dependencies by absolute path should work.
|
||||
@@ -27,6 +27,8 @@ import pathAbsolute = require('path-absolute')
|
||||
import R = require('ramda')
|
||||
import renderHelp = require('render-help')
|
||||
|
||||
const isWindows = process.platform === 'win32' || global['FAKE_WINDOWS']
|
||||
const isFilespec = isWindows ? /^(?:[.]|~[/]|[/\\]|[a-zA-Z]:)/ : /^(?:[.]|~[/]|[/]|[a-zA-Z]:)/
|
||||
const installLimit = pLimit(4)
|
||||
|
||||
export const rcOptionsTypes = cliOptionsTypes
|
||||
@@ -80,7 +82,7 @@ export async function handler (
|
||||
| 'saveProd'
|
||||
| 'workspaceDir'
|
||||
> & Partial<Pick<Config, 'globalDir' | 'linkWorkspacePackages'>>,
|
||||
params: string[]
|
||||
params?: string[]
|
||||
) {
|
||||
const cwd = opts?.dir ?? process.cwd()
|
||||
|
||||
@@ -116,7 +118,7 @@ export async function handler (
|
||||
return
|
||||
}
|
||||
|
||||
const [pkgPaths, pkgNames] = R.partition((inp) => inp.startsWith('.'), params)
|
||||
const [pkgPaths, pkgNames] = R.partition((inp) => isFilespec.test(inp), params)
|
||||
|
||||
if (pkgNames.length) {
|
||||
let globalPkgNames!: string[]
|
||||
|
||||
@@ -105,6 +105,38 @@ test('relative link', async () => {
|
||||
expect(currentLockfile.dependencies['hello-world-js-bin']).toBe('link:../hello-world-js-bin') // link added to wanted lockfile
|
||||
})
|
||||
|
||||
test('absolute link', async () => {
|
||||
const project = prepare({
|
||||
dependencies: {
|
||||
'hello-world-js-bin': '*',
|
||||
},
|
||||
})
|
||||
|
||||
const linkedPkgName = 'hello-world-js-bin'
|
||||
const linkedPkgPath = path.resolve('..', linkedPkgName)
|
||||
|
||||
await copyFixture(linkedPkgName, linkedPkgPath)
|
||||
await link.handler({
|
||||
...DEFAULT_OPTS,
|
||||
dir: process.cwd(),
|
||||
npmGlobalBinDir: '',
|
||||
}, [linkedPkgPath])
|
||||
|
||||
await project.isExecutable('.bin/hello-world-js-bin')
|
||||
|
||||
// The linked package has been installed successfully as well with bins linked
|
||||
// to node_modules/.bin
|
||||
const linkedProject = assertProject(linkedPkgPath)
|
||||
await linkedProject.isExecutable('.bin/cowsay')
|
||||
|
||||
const wantedLockfile = await project.readLockfile()
|
||||
expect(wantedLockfile.dependencies['hello-world-js-bin']).toBe('link:../hello-world-js-bin') // link added to wanted lockfile
|
||||
expect(wantedLockfile.specifiers['hello-world-js-bin']).toBe('*') // specifier of linked dependency added to ${WANTED_LOCKFILE}
|
||||
|
||||
const currentLockfile = await project.readCurrentLockfile()
|
||||
expect(currentLockfile.dependencies['hello-world-js-bin']).toBe('link:../hello-world-js-bin') // link added to wanted lockfile
|
||||
})
|
||||
|
||||
test('link --production', async () => {
|
||||
const projects = preparePackages([
|
||||
{
|
||||
|
||||
Reference in New Issue
Block a user