Skip to content

Commit

Permalink
fix: don't run prepublishOnly and prepublish on pack
Browse files Browse the repository at this point in the history
close #2941
  • Loading branch information
zkochan committed Jan 20, 2023
1 parent 5bede17 commit 83fad33
Show file tree
Hide file tree
Showing 4 changed files with 15 additions and 5 deletions.
6 changes: 6 additions & 0 deletions .changeset/thin-keys-march.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
---
"@pnpm/plugin-commands-publishing": major
"pnpm": major
---

`prepublishOnly` and `prepublish` should not be executed on `pnpm pack` [#2941](https://github.com/pnpm/pnpm/issues/2941).
4 changes: 1 addition & 3 deletions releasing/plugin-commands-publishing/src/pack.ts
Original file line number Diff line number Diff line change
Expand Up @@ -77,10 +77,8 @@ export async function handler (
})
if (!opts.ignoreScripts) {
await _runScriptsIfPresent([
'prepublish',
'prepare',
'prepublishOnly',
'prepack',
'prepare',
], entryManifest)
}
const dir = entryManifest.publishConfig?.directory
Expand Down
6 changes: 6 additions & 0 deletions releasing/plugin-commands-publishing/src/publish.ts
Original file line number Diff line number Diff line change
Expand Up @@ -198,6 +198,12 @@ Do you want to continue?`,
args.splice(index, 2)
}
}
if (!opts.ignoreScripts) {
await _runScriptsIfPresent([
'prepublishOnly',
'prepublish',
], manifest)
}

// We have to publish the tarball from another location.
// Otherwise, npm would publish the package with the package.json file
Expand Down
4 changes: 2 additions & 2 deletions releasing/plugin-commands-publishing/test/publish.ts
Original file line number Diff line number Diff line change
Expand Up @@ -645,10 +645,10 @@ test('publish: runs all the lifecycle scripts', async () => {

const { default: outputs } = await import(path.resolve('output.json'))
expect(outputs).toStrictEqual([
'prepublish',
'prepare',
'prepublishOnly',
'prepublish',
'prepack',
'prepare',
'publish',
'postpublish',
])
Expand Down

0 comments on commit 83fad33

Please sign in to comment.