Skip to content

Commit

Permalink
fix(changelog): allow saving context to a file (#138)
Browse files Browse the repository at this point in the history
  • Loading branch information
orhun committed Jan 18, 2023
1 parent 336b25f commit 08ea900
Showing 1 changed file with 6 additions and 1 deletion.
7 changes: 6 additions & 1 deletion git-cliff/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -333,7 +333,12 @@ pub fn run(mut args: Opt) -> Result<()> {
// Generate output.
let changelog = Changelog::new(releases, &config)?;
if args.context {
return changelog.write_context(&mut io::stdout());
return if let Some(path) = args.output {
let mut output = File::create(path)?;
changelog.write_context(&mut output)
} else {
changelog.write_context(&mut io::stdout())
};
}
if let Some(path) = args.prepend {
changelog.prepend(fs::read_to_string(&path)?, &mut File::create(path)?)?;
Expand Down

0 comments on commit 08ea900

Please sign in to comment.