Skip to content

Commit 7c2c68b

Browse files
committed
fix: add workaround so that pnpm@5 can pack regular packages
1 parent c8e6f36 commit 7c2c68b

File tree

2 files changed

+5
-6
lines changed

2 files changed

+5
-6
lines changed

packages/gatsby/content/features/protocols.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -52,7 +52,7 @@ [email protected]:yarnpkg/berry.git#head=master
5252

5353
- Yarn will use either of Yarn, npm, or pnpm to pack the repository, based on the repository style (ie we'll use Yarn if there's a `yarn.lock`, npm if there's a `package-lock.json`, or pnpm if there's a `pnpm-lock.yaml`)
5454

55-
- Workspaces can be cloned as long as the remote repository uses Yarn, npm (npm@>=7.x has to be installed on the system), or pnpm. Just reference the workspace by name in your range (you can optionally enforce the tag as well):
55+
- Workspaces can be cloned as long as the remote repository uses Yarn, npm (npm@>=7.x has to be installed on the system), or pnpm (pnpm@>=6.x has to be installed on the system). Just reference the workspace by name in your range (you can optionally enforce the tag as well):
5656

5757
```
5858
[email protected]:yarnpkg/berry.git#workspace=@yarnpkg/shell&tag=@yarnpkg/shell/2.1.0

packages/yarnpkg-core/sources/scriptUtils.ts

Lines changed: 4 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -350,10 +350,6 @@ export async function prepareExternalProject(cwd: PortablePath, outputPath: Port
350350
}],
351351

352352
[PackageManager.Pnpm, async () => {
353-
const workspaceCli = workspace !== null
354-
? [`--filter`, workspace]
355-
: [];
356-
357353
const install = await execUtils.pipevp(`pnpm`, [`install`], {cwd, env, stdin, stdout, stderr, end: execUtils.EndStrategy.ErrorCode});
358354
if (install.code !== 0)
359355
return install.code;
@@ -368,7 +364,10 @@ export async function prepareExternalProject(cwd: PortablePath, outputPath: Port
368364

369365
// - `pnpm pack` doesn't support the `--filter` flag so we have to use `pnpm exec`
370366
// - We have to use the `--pack-destination` flag because otherwise pnpm generates the tarball inside the workspace cwd
371-
const packArgs = [...workspaceCli, `exec`, `pnpm`, `pack`, `--pack-destination`, npath.fromPortablePath(cwd)];
367+
// - Only pnpm@>=6.x supports the `--pack-destination` flag (and previous versions throw an error)
368+
const packArgs = workspace !== null
369+
? [`--filter`, workspace, `exec`, `pnpm`, `pack`, `--pack-destination`, npath.fromPortablePath(cwd)]
370+
: [`pack`];
372371

373372
const pack = await execUtils.pipevp(`pnpm`, packArgs, {cwd, env, stdin, stdout: packStream, stderr});
374373
if (pack.code !== 0)

0 commit comments

Comments
 (0)