Skip to content

Commit d348943

Browse files
committed
feat(cli)!: show changelog in CLI unless bumping or releasing
1 parent 8487e91 commit d348943

File tree

2 files changed

+21
-5
lines changed

2 files changed

+21
-5
lines changed

README.md

Lines changed: 13 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,12 +9,24 @@
99
1010
## Quick Start
1111

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

1414
```sh
1515
npx changelogen@latest
1616
```
1717

18+
Generate changelog, bump version in `package.json` automatically and update `CHANGELOG.md` (without commit)
19+
20+
```sh
21+
npx changelogen@latest --bump
22+
```
23+
24+
Bump version, update `CHANGELOG.md` and make a git commit and tag:
25+
26+
```sh
27+
npx changelogen@latest --release
28+
```
29+
1830
## CLI Usage
1931

2032
```sh

src/cli.ts

Lines changed: 8 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -34,8 +34,14 @@ async function main () {
3434
// Generate markdown
3535
const markdown = generateMarkDown(commits, config)
3636

37-
// Update changelog file
38-
if (config.output) {
37+
// Show changelog in CLI unless bumping or releasing
38+
const displayOnly = !args.bump && !args.release
39+
if (displayOnly) {
40+
consola.log('\n\n' + markdown + '\n\n')
41+
}
42+
43+
// Update changelog file (only when bumping or releasing or when --output is specified as a file)
44+
if (config.output && (args.output || !displayOnly)) {
3945
let changelogMD: string
4046
if (existsSync(config.output)) {
4147
consola.info(`Updating ${config.output}`)
@@ -57,8 +63,6 @@ async function main () {
5763
}
5864

5965
await fsp.writeFile(config.output, changelogMD)
60-
} else {
61-
consola.log('\n\n' + markdown + '\n\n')
6266
}
6367

6468
// Bump version optionally

0 commit comments

Comments
 (0)