Skip to content

Commit 71a0193

Browse files
authored
fix #196 (#197)
* fix behaviour with pre and post * forgot this
1 parent 124af03 commit 71a0193

2 files changed

Lines changed: 12 additions & 1 deletion

File tree

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
---
2+
"@changesets/cli": patch
3+
---
4+
5+
Close off error when running publish where individual packages have pre or post hooks.
6+
7+
Under the previous behaviour, JSON parsing the response to publish failed, causing git tags to not be created.

‎packages/cli/src/commands/publish/npm-utils.ts‎

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -124,8 +124,12 @@ async function internalPublish(
124124
cwd: opts.cwd,
125125
env: Object.assign({}, process.env, envOverride)
126126
});
127+
// New error handling. NPM's --json option is included alongside the `prepublish and
128+
// `postpublish` contents in terminal. We want to handle this as best we can but it has
129+
// some struggles
130+
// Note that both pre and post publish hooks are printed before the json out, so this works.
131+
let json = JSON.parse(stdout.toString().replace(/[^{]*/, ""));
127132

128-
let json = JSON.parse(stdout.toString());
129133
if (json.error) {
130134
if (json.error.code === "EOTP" && !isCI) {
131135
if (twoFactorState.token !== null) {

0 commit comments

Comments
 (0)