Skip to content

Commit 01e62a1

Browse files
iorateclaude
andauthored
Keep the stderr report when version --output is given (#202)
Co-authored-by: Claude Fable 5.1 <noreply@anthropic.com>
1 parent 8fb620c commit 01e62a1

4 files changed

Lines changed: 28 additions & 19 deletions

File tree

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
---
2+
changesette: patch
3+
---
4+
5+
`version --output` no longer suppresses the report of bumped packages and updated dependencies on stderr.

‎README.md‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -285,7 +285,7 @@ Applies all pending changesets: bumps each released package's `package.json`, in
285285

286286
`--allow-unreleased-dependencies` succeeds even when a released package depends on a skipped package with unreleased changes.
287287

288-
`--output` (short form `-o`) suppresses the report and writes the release plan to the given file (`-` for stdout) as JSON, extending the changesets `ReleasePlan` type with `dir` and `changelogEntry`:
288+
`--output` (short form `-o`) also writes the release plan to the given file (`-` for stdout) as JSON, extending the changesets `ReleasePlan` type with `dir` and `changelogEntry`:
289289

290290
```json
291291
{

‎src/commands/version.rs‎

Lines changed: 17 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -89,28 +89,28 @@ pub fn run(workspace: Workspace, config: &Config, args: VersionArgs) -> Result<(
8989
}
9090
}
9191

92-
if let Some(path) = &args.output {
93-
return release_plan::write_file(path, &release_plan::build(&planned));
94-
}
95-
9692
if planned.changes.is_empty() && !exiting {
9793
info!("No unreleased changesets found");
98-
return Ok(());
99-
}
100-
let mut bumped = false;
101-
for release in &planned.releases {
102-
if release.bump.is_some() {
103-
info!(
104-
"Bumped {} {} -> {}",
105-
release.name, release.old_version, release.new_version
106-
);
107-
bumped = true;
94+
} else {
95+
let mut bumped = false;
96+
for release in &planned.releases {
97+
if release.bump.is_some() {
98+
info!(
99+
"Bumped {} {} -> {}",
100+
release.name, release.old_version, release.new_version
101+
);
102+
bumped = true;
103+
}
104+
}
105+
if !bumped && !planned.changes.is_empty() {
106+
info!("No packages to bump");
108107
}
108+
report_updates(&planned);
109109
}
110-
if !bumped && !planned.changes.is_empty() {
111-
info!("No packages to bump");
110+
111+
if let Some(path) = &args.output {
112+
release_plan::write_file(path, &release_plan::build(&planned))?;
112113
}
113-
report_updates(&planned);
114114
Ok(())
115115
}
116116

‎tests/cli.rs‎

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -569,6 +569,10 @@ fn version_output_writes_the_pretty_plan_and_applies_the_changesets() {
569569
let output = changesette(dir.path(), &["version", "--output", "plan.json"]);
570570
assert!(output.status.success(), "{}", stderr(&output));
571571
assert_eq!(stdout(&output), "");
572+
assert_eq!(
573+
stderr(&output),
574+
"Bumped ublacklist 1.2.3 -> 1.3.0\nWrote the release plan to plan.json\n"
575+
);
572576
assert_eq!(
573577
fs::read_to_string(dir.path().join("plan.json")).unwrap(),
574578
pretty_plan(ID_B)
@@ -592,7 +596,7 @@ fn version_output_dash_writes_the_pretty_plan_to_stdout() {
592596
let output = changesette(dir.path(), &["version", "--output", "-"]);
593597
assert!(output.status.success(), "{}", stderr(&output));
594598
assert_eq!(stdout(&output), pretty_plan(ID_B));
595-
assert_eq!(stderr(&output), "");
599+
assert_eq!(stderr(&output), "Bumped ublacklist 1.2.3 -> 1.3.0\n");
596600
assert!(!dir.path().join("-").exists());
597601
assert!(!dir.path().join(".changeset").join(FILE_B).exists());
598602
}

0 commit comments

Comments
 (0)