npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2024 – Pkg Stats / Ryan Hefner

changelog-parser

v3.0.1

Published

Change log parser for node.

Downloads

88,149

Readme

changelog-parser

npm build downloads

Change log parser for node.

Install

npm install changelog-parser

Usage

This module exports a single function. It supports both callbacks and promises.

var parseChangelog = require('changelog-parser')

Callback

If provided with a callback, parseChangelog will invoke the function with the parsed changelog.

parseChangelog('path/to/CHANGELOG.md', function (err, result) {
  if (err) throw err

  // changelog object
  console.log(result)
})

Promise

If no callback is provided, parseChangelog will return a Promise.

parseChangelog('path/to/CHANGELOG.md')
  .then(function (result) {
    // changelog object
    console.log(result)
  })
  .catch(function (err) {
    // Whoops, something went wrong!
    console.error(err)
  })

Options

You can optionally provide a configuration object parseChangelog function.

You must provide either filePath or text.

filePath

Path to changelog file.

parseChangelog({
  filePath: 'path/to/CHANGELOG.md'
})

text

Text of changelog file (you can use this instead of filePath).

parseChangelog({
  text: 'raw changelog text in string format'
})

removeMarkdown

Removes the markdown markup from the changelog entries by default. You can change its value to false to keep the markdown.

parseChangelog({
  filePath: 'path/to/CHANGELOG.md',
  removeMarkdown: false // default: true
})

Command-line interface

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.

Standards

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 (or DD.MM.YYYY, D/M/YY, etc.)
* 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',
      date: null,
      body: '* foo',
      parsed: {
        _: [
          'foo'
        ]
      }
    },
    { version: 'x.y.z',
      title: 'x.y.z - YYYY-MM-DD',
      date: null,
      body: '* bar',
      parsed: {
        _: [
          'bar'
        ]
      }
    },
    { version: 'a.b.c',
      title: '[a.b.c]',
      date: null,
      body: '### Changes\n\n* Update API\n* Fix bug #1',
      parsed: {
        _: [
          'Update API',
          'Fix bug #1'
        ],
        Changes: [
          'Update API',
          'Fix bug #1'
        ]
      }
    },
    { version: '2.2.3-pre.1',
      title: '2.2.3-pre.1 - 2013-02-14',
      date: '2013-02-14',
      body: '* Update API',
      parsed: {
        _: [
          'Update API'
        ]
      }
    },
    { version: '2.0.0-x.7.z.92',
      title: '2.0.0-x.7.z.92 - 2013-02-14',
      date: '2013-02-14',
      body: '* bark bark\n* woof\n* arf',
      parsed: {
        _: [
          'bark bark',
          'woof',
          'arf'
        ]
      }
    },
    { version: '1.3.0',
      title: 'v1.3.0',
      date: null,
      body: '* make it so',
      parsed: {
        _: [
          'make it so'
        ]
      }
    },
    { version: '1.2.3',
      title: '[1.2.3](link)',
      date: null,
      body: '* init',
      parsed: {
        _: [
          'init'
        ]
      }
    }
  ]
}

Expects versions to be semver compliant, otherwise sets version to null.

Each entry is available as an object in the versions array. The body of a given entry can be accessed using the following properties:

  • body - A string containing all of the updates/changes/etc. for the current entry. This property includes both plain text and markdown.
  • parsed - An object which points to one or more arrays of data for the current entry. All data for the current entry is present in the array at key _ (eg. parsed._). If the entry contains subheadings (eg. ### Added, ### Changed), then any items underneath each subheading will be present in an array at the corresponding key (eg. parsed.Added, parsed.Changed). Each array contains plain text.

CHANGELOG.md standards are inspired by keepachangelog.com.

Contributing

Contributions welcome! Please read the contributing guidelines first.

See Also

License

ISC

Log image is from emojipedia.