Skip to content

Commit

Permalink
Fix double newline after streaming
Browse files Browse the repository at this point in the history
Check if the streaming command emitted two newlines before adding an extra newline for padding. This fixes the case where an extra newline was being added when it wasn't needed.
  • Loading branch information
schneems committed Feb 14, 2024
1 parent 29f1a4e commit e177d78
Showing 1 changed file with 8 additions and 6 deletions.
14 changes: 8 additions & 6 deletions libherokubuildpack/src/buildpack_output/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -510,18 +510,21 @@ where
///
/// Once you're finished streaming to the output, calling this function
/// finalizes the stream's output and transitions back to a [`state::Section`].
pub fn finish(mut self) -> BuildpackOutput<state::Section<W>> {
pub fn finish(self) -> BuildpackOutput<state::Section<W>> {
let duration = self.state.started.elapsed();

writeln_now(&mut self.state.write, "");

BuildpackOutput {
let mut output = BuildpackOutput {
started: self.started,
state: state::Section {
write: self.state.write.unwrap(),
},
};

if !output.state.write_mut().was_paragraph {
writeln_now(&mut output.state.write, "");
}
.step(format!(

output.step(format!(
"Done {}",
style::details(duration_format::human(&duration))
))
Expand Down Expand Up @@ -701,7 +704,6 @@ mod test {
{tab_char}
baz
- Done (< 0.1s)
- Done (finished in < 0.1s)
"};
Expand Down

0 comments on commit e177d78

Please sign in to comment.