Change log parser for node.
npm install changelog-parser
var parseChangelog = require('changelog-parser')
parseChangelog('path/to/CHANGELOG.md', function (err, result) {
if (err) throw err
// changelog object
console.log(result)
})
There is also a command-line interface available if you install it with -g
.
npm install -g changelog-parser
This installs a program called changelog-parser
that you simply pass a CHANGELOG.md
file.
changelog-parser path/to/CHANGELOG.md
This will print the JSON object representing the change log to the terminal.
Alternately you can run it without arguments and it will look for a CHANGELOG.md
file in the working directory.
This module assumes your change log is a markdown file structured roughly like so:
# changelog title
A cool description (optional).
## unreleased
* foo
## x.y.z - YYYY-MM-DD
* bar
## [a.b.c]
### Changes
* Update API
* Fix bug #1
## 2.2.3-pre.1 - 2013-02-14
* Update API
## 2.0.0-x.7.z.92 - 2013-02-14
* bark bark
* woof
* arf
## v1.3.0
* make it so
## [1.2.3](link)
* init
[a.b.c]: http://altavista.com
Parsing the above example will return the following object:
{
title: 'changelog title',
description: 'A cool description (optional).',
versions: [
{ version: null,
title: 'unreleased',
body: '* foo' },
{ version: 'x.y.z',
title: 'x.y.z - YYYY-MM-DD',
body: '* bar' },
{ version: 'a.b.c',
title: '[a.b.c]',
body: '### Changes\n\n* Update API\n* Fix bug #1' },
{ version: '2.2.3-pre.1',
title: '2.2.3-pre.1 - 2013-02-14',
body: '* Update API' },
{ version: '2.0.0-x.7.z.92',
title: '2.0.0-x.7.z.92 - 2013-02-14',
body: '* bark bark\n* woof\n* arf' },
{ version: '1.3.0',
title: 'v1.3.0',
body: '* make it so' },
{ version: '1.2.3',
title: '[1.2.3](link)',
body: '* init' }
]
}
Expects versions to be semver compliant, otherwise sets version
to null.
CHANGELOG.md
standards are inspired by keepachangelog.com.
Contributions welcome! Please read the contributing guidelines first.