DefinitelyTyped icon, indicating that this package has TypeScript declarations provided by the separate @types/generate-changelog package

1.8.0 • Public • Published

Generate Changelog

NPM Version Build Status Coverage Status Dependency Status

Generate a changelog from git commits. This is meant to be used so that for every patch, minor, or major version, you update the changelog prior to running npm version so that the git tag contains the commit that updated both the changelog and version.


You can either install it as a dev dependency to be referenced in your npm scripts, or you can install this module globally to be used for all of your repos on your local machine.

$ npm i generate-changelog -D # install it as a dev dependency 
# OR 
$ npm i generate-changelog -g # install it globally 


To use this module, your commit messages have to be in this format:

type(category): description [flags]

Where type is one of the following:

  • breaking
  • build
  • ci
  • chore
  • docs
  • feat
  • fix
  • other
  • perf
  • refactor
  • revert
  • style
  • test

Where flags is an optional comma-separated list of one or more of the following (must be surrounded in square brackets):

  • breaking: alters type to be a breaking change

And category can be anything of your choice. If you use a type not found in the list (but it still follows the same format of the message), it'll be grouped under other.


You can run this module as a CLI app that prepends the new logs to a file (recommended):

$ changelog -h
  Usage: generate [options]
  Generate a changelog from git commits.
    -h, --help             output usage information
    -V, --version          output the version number
    -p, --patch            create a patch changelog
    -m, --minor            create a minor changelog
    -M, --major            create a major changelog
    -t, --tag <range>      generate from specific tag or range (e.g. v1.2.3 or v1.2.3..v1.2.4)
    -x, --exclude <types>  exclude selected commit types (comma separated)
    -f, --file [file]      file to write to, defaults to ./, use - for stdout
    -u, --repo-url [url]   specify the repo URL for commit links, defaults to checking the package.json
    -a, --allow-unknown    allow unkown commit types

It's possible to create a ./ file for a specific commit range:

generate-changelog 420c945...2a83752

Git tags are supported too:

generate-changelog release/3.1.2822...release/3.1.2858


You can write a script that calls the generate function and does whatever you want with the new logs:

var Changelog = require('generate-changelog');
var Fs        = require('fs');
return Changelog.generate({ patch: true, repoUrl: '' })
.then(function (changelog) {
  Fs.writeFileSync('./', changelog);


The way that I would recommend using this module would be the way it's being used in this module: as npm scripts. You should install it as a dev dependency and then add the following to the scripts object in your package.json:

"release:major""changelog -M && git add && git commit -m 'updated' && npm version major && git push origin && git push origin --tags",
"release:minor""changelog -m && git add && git commit -m 'updated' && npm version minor && git push origin && git push origin --tags",
"release:patch""changelog -p && git add && git commit -m 'updated' && npm version patch && git push origin && git push origin --tags",


To run the test suite, just clone the repository and run the following:

$ npm i
$ npm test


To contribute, please see the file.


This project is released under the MIT license, which can be found in LICENSE.txt.

Package Sidebar


npm i generate-changelog

Weekly Downloads






Unpacked Size

25 kB

Total Files


Last publish


  • hunteryoakum
  • rdimouro7373
  • lobstertroy
  • joshnkoy
  • michel_lob
  • haroutrs
  • kjones_lob
  • eamon-barisone
  • nathanielwaldschmidtlob
  • zach.reed
  • richpodrazalob
  • kencrim
  • jorgelob
  • nick-place-lob
  • andrew.guterres
  • ajorczak
  • hanqingchen-lob
  • juan.frissdekereki
  • mmorgan-lob
  • karankwatra-lob
  • joey-bates-lob
  • luke.birdeau
  • mg-lob
  • vmangwani
  • sachinlob
  • kc-lob
  • nick.perri
  • siddharthpant92
  • bethqiang
  • kplob
  • samkitsheth95
  • erin-doyle
  • rich_seviora_lob
  • jfdavidson
  • meussdorffer
  • shannamurry
  • davidnutting-lob
  • amaan_lob
  • elijah-lob
  • jlowsley-lob
  • barnabygo
  • james.cho
  • douglaje
  • lob-owner
  • graeme.lowe.lob