Skip to content

Commit d83ca0d

Browse files
committed
🎨 better publish error logging
1 parent 8b10f2b commit d83ca0d

File tree

2 files changed

+11
-1
lines changed

2 files changed

+11
-1
lines changed

.changeset/neat-cycles-whisper.md

+5
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
---
2+
'@codeshift/publisher': patch
3+
---
4+
5+
Improve error logging on publish

packages/publisher/src/publish.ts

+6-1
Original file line numberDiff line numberDiff line change
@@ -37,14 +37,19 @@ async function publish(
3737
publishOpts.push('--dry-run');
3838
}
3939

40-
const { stdout } = await spawn(
40+
const { code, stdout, stderr } = await spawn(
4141
'npm',
4242
['publish', pkg.dir, '--json', ...publishOpts],
4343
{
4444
env: Object.assign({}, process.env, envOverride),
4545
},
4646
);
4747

48+
if (code !== 0) {
49+
console.log(chalk.cyan(stderr));
50+
throw new Error(`An error occurred while publishing ${name}`);
51+
}
52+
4853
const json = jsonParse(stdout.toString().replace(/[^{]*/, ''));
4954

5055
if (json.error) {

0 commit comments

Comments
 (0)