mirror of
https://github.com/pnpm/pnpm.git
synced 2026-02-09 06:32:17 -05:00
5
.changeset/orange-apes-scream.md
Normal file
5
.changeset/orange-apes-scream.md
Normal file
@@ -0,0 +1,5 @@
|
||||
---
|
||||
"@pnpm/plugin-commands-installation": patch
|
||||
---
|
||||
|
||||
add path join and add test case for pnpm --dir <path> link global
|
||||
5
.changeset/stale-rice-nail.md
Normal file
5
.changeset/stale-rice-nail.md
Normal file
@@ -0,0 +1,5 @@
|
||||
---
|
||||
"@pnpm/plugin-commands-installation": patch
|
||||
---
|
||||
|
||||
fix error in pnpm --dir <path> link --global
|
||||
@@ -116,7 +116,7 @@ export async function handler (
|
||||
const { manifest, writeProjectManifest } = await tryReadProjectManifest(opts.dir, opts)
|
||||
const newManifest = await addDependenciesToPackage(
|
||||
manifest ?? {},
|
||||
[`link:${cwd}`],
|
||||
[`link:${opts.cliOptions?.dir ? path.join(cwd, opts.cliOptions.dir) : cwd}`],
|
||||
linkOpts
|
||||
)
|
||||
await writeProjectManifest(newManifest)
|
||||
|
||||
@@ -72,6 +72,32 @@ test('link global bin', async function () {
|
||||
await isExecutable((value) => expect(value).toBeTruthy(), path.join(globalBin, 'package-with-bin'))
|
||||
})
|
||||
|
||||
test('link --dir global bin', async function () {
|
||||
prepare()
|
||||
process.chdir('..')
|
||||
|
||||
const globalDir = path.resolve('global')
|
||||
const globalBin = path.join(globalDir, 'bin')
|
||||
const oldPath = process.env[PATH]
|
||||
process.env[PATH] = `${globalBin}${path.delimiter}${oldPath ?? ''}`
|
||||
await fs.mkdir(globalBin, { recursive: true })
|
||||
|
||||
await writePkg('./dir/package-with-bin-in-dir', { name: 'package-with-bin-in-dir', version: '1.0.0', bin: 'bin.js' })
|
||||
await fs.writeFile('./dir/package-with-bin-in-dir/bin.js', '#!/usr/bin/env node\nconsole.log(/hi/)\n', 'utf8')
|
||||
|
||||
await link.handler({
|
||||
...DEFAULT_OPTS,
|
||||
cliOptions: {
|
||||
dir: './dir/package-with-bin-in-dir',
|
||||
},
|
||||
bin: globalBin,
|
||||
dir: globalDir,
|
||||
})
|
||||
process.env[PATH] = oldPath
|
||||
|
||||
await isExecutable((value) => expect(value).toBeTruthy(), path.join(globalBin, 'package-with-bin-in-dir'))
|
||||
})
|
||||
|
||||
test('relative link', async () => {
|
||||
const project = prepare({
|
||||
dependencies: {
|
||||
|
||||
Reference in New Issue
Block a user