From 17d2ddb056052a0115e7392dfab0c075b523ab6e Mon Sep 17 00:00:00 2001 From: Zoltan Kochan Date: Fri, 15 Sep 2023 17:04:28 +0300 Subject: [PATCH] fix: don't run prepublishOnly of git-hosted dependencies (#7096) close #7026 --- .changeset/metal-starfishes-decide.md | 6 ++++++ exec/prepare-package/src/index.ts | 4 +++- pkg-manager/core/test/install/lifecycleScripts.ts | 1 - 3 files changed, 9 insertions(+), 2 deletions(-) create mode 100644 .changeset/metal-starfishes-decide.md diff --git a/.changeset/metal-starfishes-decide.md b/.changeset/metal-starfishes-decide.md new file mode 100644 index 0000000000..9eb4f80901 --- /dev/null +++ b/.changeset/metal-starfishes-decide.md @@ -0,0 +1,6 @@ +--- +"@pnpm/prepare-package": patch +"pnpm": patch +--- + +Don't run the `prepublishOnly` scripts of git-hosted dependencies [#7026](https://github.com/pnpm/pnpm/issues/7026). diff --git a/exec/prepare-package/src/index.ts b/exec/prepare-package/src/index.ts index fc4d612df7..c4ef706610 100644 --- a/exec/prepare-package/src/index.ts +++ b/exec/prepare-package/src/index.ts @@ -7,9 +7,11 @@ import rimraf from '@zkochan/rimraf' import preferredPM from 'preferred-pm' import omit from 'ramda/src/omit' +// We don't run prepublishOnly to prepare the dependency. +// This might be counterintuitive as prepublishOnly is where a lot of packages put their build scripts. +// However, neither npm nor Yarn run prepublishOnly of git-hosted dependencies (checked on npm v10 and Yarn v3). const PREPUBLISH_SCRIPTS = [ 'prepublish', - 'prepublishOnly', 'prepack', 'publish', ] diff --git a/pkg-manager/core/test/install/lifecycleScripts.ts b/pkg-manager/core/test/install/lifecycleScripts.ts index dad2ad57ad..3d74f86bc9 100644 --- a/pkg-manager/core/test/install/lifecycleScripts.ts +++ b/pkg-manager/core/test/install/lifecycleScripts.ts @@ -278,7 +278,6 @@ test('run prepare script for git-hosted dependencies', async () => { 'install', 'postinstall', 'prepare', - 'prepublishOnly', 'preinstall', 'install', 'postinstall',