Skip to content

Commit

Permalink
add --prepend option as altenative to prepend-token (#172)
Browse files Browse the repository at this point in the history
* add --prepend option as altenative to prepend-token

* Tweak --prepend option

Co-authored-by: Pete Cook <pete@cookpete.com>
  • Loading branch information
mansona and cookpete authored Jul 3, 2020
1 parent 0687370 commit cc1ef37
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 1 deletion.
1 change: 1 addition & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -47,6 +47,7 @@ Options:
--hide-credit # hide auto-changelog credit
--handlebars-setup [file] # handlebars setup file
--append-git-log [string] # string to append to git log command
--prepend # prepend changelog to output file
--stdout # output changelog to stdout
-V, --version # output the version number
-h, --help # output usage information
Expand Down
3 changes: 2 additions & 1 deletion src/run.js
Original file line number Diff line number Diff line change
Expand Up @@ -51,6 +51,7 @@ async function getOptions (argv) {
.option('--hide-credit', 'hide auto-changelog credit')
.option('--handlebars-setup <file>', 'handlebars setup file')
.option('--append-git-log <string>', 'string to append to git log command')
.option('--prepend', 'prepend changelog to output file')
.option('--stdout', 'output changelog to stdout')
.version(version)
.parse(argv)
Expand Down Expand Up @@ -109,7 +110,7 @@ async function write (changelog, options, log) {
const bytes = Buffer.byteLength(changelog, 'utf8')
const existing = await fileExists(options.output) && await readFile(options.output, 'utf8')
if (existing) {
const index = existing.indexOf(PREPEND_TOKEN)
const index = options.prepend ? 0 : existing.indexOf(PREPEND_TOKEN)
if (index !== -1) {
const prepended = `${changelog}\n${existing.slice(index)}`
await writeFile(options.output, prepended)
Expand Down

0 comments on commit cc1ef37

Please sign in to comment.