Skip to content

Commit

Permalink
deps(dev): tape@5, tap-spec@5, standard@16, gh-release@6 (#38)
Browse files Browse the repository at this point in the history
* deps(dev): tape@5, tap-spec@5

* deps(dev): standard@16

* deps(dev): gh-release@6
  • Loading branch information
ungoldman committed Mar 14, 2022
1 parent 35ce4b4 commit 9704121
Show file tree
Hide file tree
Showing 6 changed files with 62 additions and 62 deletions.
6 changes: 3 additions & 3 deletions bin/cli.js
@@ -1,8 +1,8 @@
#!/usr/bin/env node

var parseChangelog = require('..')
var file = process.argv[2] || 'CHANGELOG.md'
var help = process.argv[2] === '-h' || process.argv[2] === '--help'
const parseChangelog = require('..')
const file = process.argv[2] || 'CHANGELOG.md'
const help = process.argv[2] === '-h' || process.argv[2] === '--help'

if (help) {
console.log('usage: changelog-parser [filename]')
Expand Down
38 changes: 19 additions & 19 deletions index.js
@@ -1,14 +1,14 @@
var EOL = require('os').EOL
var lineReader = require('line-reader')
var removeMarkdown = require('remove-markdown')
const EOL = require('os').EOL
const lineReader = require('line-reader')
const removeMarkdown = require('remove-markdown')

// patterns
var semver = /\[?v?([\w\d.-]+\.[\w\d.-]+[a-zA-Z0-9])\]?/
var date = /.*[ ](\d\d?\d?\d?[-/.]\d\d?[-/.]\d\d?\d?\d?).*/
var subhead = /^###/
var listitem = /^[*-]/
const semver = /\[?v?([\w\d.-]+\.[\w\d.-]+[a-zA-Z0-9])\]?/
const date = /.*[ ](\d\d?\d?\d?[-/.]\d\d?[-/.]\d\d?\d?\d?).*/
const subhead = /^###/
const listitem = /^[*-]/

var defaultOptions = { removeMarkdown: true }
const defaultOptions = { removeMarkdown: true }

/**
* Changelog parser.
Expand All @@ -24,10 +24,10 @@ function parseChangelog (options, callback) {
if (typeof options === 'undefined') throw new Error('missing options argument')
if (typeof options === 'string') options = { filePath: options }
if (typeof options === 'object') {
var hasFilePath = typeof options.filePath !== 'undefined'
var hasText = typeof options.text !== 'undefined'
var invalidFilePath = typeof options.filePath !== 'string'
var invalidText = typeof options.text !== 'string'
const hasFilePath = typeof options.filePath !== 'undefined'
const hasText = typeof options.text !== 'undefined'
const invalidFilePath = typeof options.filePath !== 'string'
const invalidText = typeof options.text !== 'string'

if (!hasFilePath && !hasText) {
throw new Error('must provide filePath or text')
Expand All @@ -42,8 +42,8 @@ function parseChangelog (options, callback) {
}
}

var opts = Object.assign({}, defaultOptions, options)
var changelog = parse(opts)
const opts = Object.assign({}, defaultOptions, options)
const changelog = parse(opts)

if (typeof callback === 'function') {
changelog
Expand All @@ -65,15 +65,15 @@ function parseChangelog (options, callback) {
* @returns {Promise<object>} - parsed changelog object
*/
function parse (options) {
var filePath = options.filePath
var text = options.text
var data = {
const filePath = options.filePath
const text = options.text
const data = {
log: { versions: [] },
current: null
}

// allow `handleLine` to mutate log/current data as `this`.
var cb = handleLine.bind(data, options)
const cb = handleLine.bind(data, options)

return new Promise(function (resolve, reject) {
function done () {
Expand Down Expand Up @@ -138,7 +138,7 @@ function handleLine (options, line) {
// - 'handleize' subhead.
// - add subhead to 'parsed' data if not already present.
if (subhead.exec(line)) {
var key = line.replace('###', '').trim()
const key = line.replace('###', '').trim()

if (!this.current.parsed[key]) {
this.current.parsed[key] = []
Expand Down
8 changes: 4 additions & 4 deletions package.json
Expand Up @@ -23,10 +23,10 @@
"remove-markdown": "^0.2.2"
},
"devDependencies": {
"gh-release": "^3.1.1",
"standard": "^10.0.2",
"tap-spec": "^4.1.1",
"tape": "^4.6.0"
"gh-release": "^6.0.1",
"standard": "^16.0.4",
"tap-spec": "^5.0.0",
"tape": "^5.5.2"
},
"homepage": "https://github.com/hypermodules/changelog-parser",
"keywords": [
Expand Down
18 changes: 9 additions & 9 deletions test/fixtures/expected.js
@@ -1,4 +1,4 @@
var EOL = require('os').EOL
const EOL = require('os').EOL

module.exports = {
title: 'changelog title',
Expand All @@ -7,7 +7,7 @@ module.exports = {
{
version: null,
title: 'unreleased',
'date': null,
date: null,
body: '* foo',
parsed: {
_: [
Expand All @@ -18,7 +18,7 @@ module.exports = {
{
version: 'x.y.z',
title: 'x.y.z - YYYY-MM-DD',
'date': null,
date: null,
body: '* bar',
parsed: {
_: [
Expand All @@ -29,7 +29,7 @@ module.exports = {
{
version: 'a.b.c',
title: '[a.b.c]',
'date': null,
date: null,
body: '### Changes' + EOL + EOL + '* Update API' + EOL + '* Fix bug #1',
parsed: {
_: [
Expand All @@ -45,7 +45,7 @@ module.exports = {
{
version: '2.3.0',
title: '2.3.0 - 2018-12-18',
'date': '2018-12-18',
date: '2018-12-18',
body: '### Added' + EOL + EOL + '- Some changelog generators such as [standard-version](https://github.com/conventional-changelog/standard-version) would produce H1s for major versions and H2s for minor versions. We want the parser to be able to parse both.',
parsed: {
_: [
Expand All @@ -59,7 +59,7 @@ module.exports = {
{
version: '2.2.3-pre.1',
title: '2.2.3-pre.1 - 2013-02-14',
'date': '2013-02-14',
date: '2013-02-14',
body: '### Added' + EOL + '- Added an item.' + EOL + '* Added another item.' + EOL + EOL + '* Update API',
parsed: {
_: [
Expand All @@ -77,7 +77,7 @@ module.exports = {
{
version: '2.0.0-x.7.z.92',
title: '2.0.0-x.7.z.92 - 2013-02-14',
'date': '2013-02-14',
date: '2013-02-14',
body: '* bark bark' + EOL + '* woof' + EOL + '* arf',
parsed: {
_: [
Expand All @@ -90,7 +90,7 @@ module.exports = {
{
version: '1.3.0',
title: 'v1.3.0',
'date': null,
date: null,
body: '* make it so',
parsed: {
_: [
Expand All @@ -101,7 +101,7 @@ module.exports = {
{
version: '1.2.3',
title: '[1.2.3](link)',
'date': null,
date: null,
body: '* init',
parsed: {
_: [
Expand Down
18 changes: 9 additions & 9 deletions test/fixtures/remove-markdown-expected.js
@@ -1,4 +1,4 @@
var EOL = require('os').EOL
const EOL = require('os').EOL

module.exports = {
title: 'changelog title',
Expand All @@ -7,7 +7,7 @@ module.exports = {
{
version: null,
title: 'unreleased',
'date': null,
date: null,
body: '* foo',
parsed: {
_: [
Expand All @@ -18,7 +18,7 @@ module.exports = {
{
version: 'x.y.z',
title: 'x.y.z - YYYY-MM-DD',
'date': null,
date: null,
body: '* bar',
parsed: {
_: [
Expand All @@ -29,7 +29,7 @@ module.exports = {
{
version: 'a.b.c',
title: '[a.b.c]',
'date': null,
date: null,
body: '### Changes' + EOL + EOL + '* Update API' + EOL + '* Fix bug #1',
parsed: {
_: [
Expand All @@ -45,7 +45,7 @@ module.exports = {
{
version: '2.3.0',
title: '2.3.0 - 2018-12-18',
'date': '2018-12-18',
date: '2018-12-18',
body: '### Added' + EOL + EOL + '- Some changelog generators such as [standard-version](https://github.com/conventional-changelog/standard-version) would produce H1s for major versions and H2s for minor versions. We want the parser to be able to parse both.',
parsed: {
_: [
Expand All @@ -59,7 +59,7 @@ module.exports = {
{
version: '2.2.3-pre.1',
title: '2.2.3-pre.1 - 2013-02-14',
'date': '2013-02-14',
date: '2013-02-14',
body: '### Added' + EOL + '- Added an item.' + EOL + '* Added another item.' + EOL + EOL + '* Update API',
parsed: {
_: [
Expand All @@ -77,7 +77,7 @@ module.exports = {
{
version: '2.0.0-x.7.z.92',
title: '2.0.0-x.7.z.92 - 2013-02-14',
'date': '2013-02-14',
date: '2013-02-14',
body: '* bark bark' + EOL + '* woof' + EOL + '* arf',
parsed: {
_: [
Expand All @@ -90,7 +90,7 @@ module.exports = {
{
version: '1.3.0',
title: 'v1.3.0',
'date': null,
date: null,
body: '* make it so',
parsed: {
_: [
Expand All @@ -101,7 +101,7 @@ module.exports = {
{
version: '1.2.3',
title: '[1.2.3](link)',
'date': null,
date: null,
body: '* init',
parsed: {
_: [
Expand Down
36 changes: 18 additions & 18 deletions test/index.js
@@ -1,17 +1,17 @@
var parseChangelog = require('..')
var test = require('tape')
var path = require('path')
var fs = require('fs')
var expected = require('./fixtures/expected')
var removeMarkdownExpected = require('./fixtures/remove-markdown-expected')
var filePath = path.join(__dirname, 'fixtures', 'CHANGELOG.md')
const parseChangelog = require('..')
const test = require('tape')
const path = require('path')
const fs = require('fs')
const expected = require('./fixtures/expected')
const removeMarkdownExpected = require('./fixtures/remove-markdown-expected')
const filePath = path.join(__dirname, 'fixtures', 'CHANGELOG.md')

test('throws on bad params', function (t) {
t.plan(3)

var missing = 'must provide filePath or text'
var invalidPath = 'invalid filePath, expected string'
var invalidText = 'invalid text, expected string'
const missing = 'must provide filePath or text'
const invalidPath = 'invalid filePath, expected string'
const invalidText = 'invalid text, expected string'

t.throws(parseChangelog, missing, missing)
t.throws(function () {
Expand All @@ -36,7 +36,7 @@ test('parses example changelog', function (t) {
test('parses example changelog as text', function (t) {
t.plan(1)

parseChangelog({text: fs.readFileSync(filePath, 'utf8')}, function (err, result) {
parseChangelog({ text: fs.readFileSync(filePath, 'utf8') }, function (err, result) {
if (err) throw err

t.deepEqual(result, expected)
Expand All @@ -47,7 +47,7 @@ test('parses example changelog as text', function (t) {
test('returns a Promise when invoked without a valid `callback`', function (t) {
t.plan(2)

var result = parseChangelog(filePath)
const result = parseChangelog(filePath)

t.true(typeof result === 'object')
t.true(result instanceof Promise)
Expand All @@ -69,11 +69,11 @@ test('callback and Promise methods should yield identical values', function (t)
if (err) t.fail()

parseChangelog(filePath)
.then(function (resultB) {
t.deepEqual(resultA, resultB)
t.end()
})
.catch(t.fail)
.then(function (resultB) {
t.deepEqual(resultA, resultB)
t.end()
})
.catch(t.fail)
})
})

Expand All @@ -91,7 +91,7 @@ test('accepts object as first argument', function (t) {
test('accepts { removeMardown: false } option', function (t) {
t.plan(1)

var options = {
const options = {
filePath: filePath,
removeMarkdown: false
}
Expand Down

0 comments on commit 9704121

Please sign in to comment.