Skip to content

Commit

Permalink
feat(cli)!: show changelog in CLI unless bumping or releasing
Browse files Browse the repository at this point in the history
  • Loading branch information
pi0 committed Sep 1, 2022
1 parent 8487e91 commit d348943
Show file tree
Hide file tree
Showing 2 changed files with 21 additions and 5 deletions.
14 changes: 13 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -9,12 +9,24 @@
## Quick Start

Generate changelog in markdown format and update (or create) `CHANGELOG.md`:
Generate changelog in markdown format and show in console:

```sh
npx changelogen@latest
```

Generate changelog, bump version in `package.json` automatically and update `CHANGELOG.md` (without commit)

```sh
npx changelogen@latest --bump
```

Bump version, update `CHANGELOG.md` and make a git commit and tag:

```sh
npx changelogen@latest --release
```

## CLI Usage

```sh
Expand Down
12 changes: 8 additions & 4 deletions src/cli.ts
Original file line number Diff line number Diff line change
Expand Up @@ -34,8 +34,14 @@ async function main () {
// Generate markdown
const markdown = generateMarkDown(commits, config)

// Update changelog file
if (config.output) {
// Show changelog in CLI unless bumping or releasing
const displayOnly = !args.bump && !args.release
if (displayOnly) {
consola.log('\n\n' + markdown + '\n\n')
}

// Update changelog file (only when bumping or releasing or when --output is specified as a file)
if (config.output && (args.output || !displayOnly)) {
let changelogMD: string
if (existsSync(config.output)) {
consola.info(`Updating ${config.output}`)
Expand All @@ -57,8 +63,6 @@ async function main () {
}

await fsp.writeFile(config.output, changelogMD)
} else {
consola.log('\n\n' + markdown + '\n\n')
}

// Bump version optionally
Expand Down

0 comments on commit d348943

Please sign in to comment.