Closed favna closed 5 months ago
Thanks for the issue! The following command works if you want to both prepend and save it to a file:
$ git-cliff -p CHANGELOG.md -l -o OTHER.md
I am guessing if we support -
for stdout then it will be even more convenient, e.g. git-cliff -p 1.md -l -o - > 2.md
What do you think of this?
Hm that might work but I'd like to try it from a WIP branch to be sure because I'm not sure how execa from Node handles trailing -
to send it to stdout.
Sure, I can implement it soon and you can probably check it out from the PR!
Boop boop #644
Is there an existing issue or pull request for this?
Feature description
Currently when
--prepend
is provided git-cliff will output the generated CHANGELOG section for the desired release to the file that is provided through--prepend
. It would be nice if it could also be send to the STDOUT through a flag so it can be picked up for further processing. It should be noted that if--prepend
is not provided then git-cliff does print to stdout.The motivation for this feature is that I could then use it for @favware/cliff-jumper to capture it and send it to the body of a GitHub release when calling the Create Release API endpoint. Currently, my CLI stops after updating the changelog and creating the Git tag locally, but if I can capture the release body I can make it possible to push the Git tag to the remote repository and create a release from that tag so a full release flow can be automated.
Desired solution
--stdout
, which when paired with--prepend ./CHANGELOG.md
will write to both theCHANGELOG.md
to print to stdout. Documentation would be able to clarify what the behaviour is of combining these 2 options.--output /dev/stdout/ --output ./CHANGELOG.md
. The equivalent of only--prepend ./CHANGELOG.md
would then be--prepend ./CHANGELOG.md --output ./CHANGELOG.md
--output
is not provided the current behaviour is retained, however in my opinion this becomes confusing because then what is going to happen if the user provides options like--prepend ./CHANGELOG.md --output ./CHANGELOG.md
/dev/stdout/
, I do not know for sure if this will work for Windows users. I would prefer if I do not have to do OS checking in @favware/cliff-jumper to account for this. With the former solution of--stdout
the advantage is that as a user of git-cliff I do not need to think about how exactly I can write to stdout for my operating system as git-cliff will automatically do that.Alternatives considered
Running git-cliff twice, first to print to stdout without
--prepend
and then toCHANGELOG.md
file with--prepend
. This is less ideal because of the "run twice" factor.Additional context
Also discussed on Discord here: https://discord.com/channels/1093977388892819553/1093978266135707668/1237529889113112607