keep-a-changelog
Advanced tools
Comparing version 0.6.3 to 0.6.4
@@ -8,2 +8,9 @@ # Changelog | ||
## [0.6.4] - 2018-09-03 | ||
### Added | ||
- Added `findRelease` function to `Changelog` for finding a release by version number - [#6] | ||
- Added `setVersion` function to `Release` for changing the version of a release - [#6] | ||
## [0.6.3] - 2018-08-22 | ||
@@ -111,2 +118,3 @@ | ||
[#6]: https://github.com/oscarotero/keep-a-changelog/issues/6 | ||
[#5]: https://github.com/oscarotero/keep-a-changelog/issues/5 | ||
@@ -117,2 +125,3 @@ [#4]: https://github.com/oscarotero/keep-a-changelog/issues/4 | ||
[0.6.4]: https://github.com/oscarotero/keep-a-changelog/compare/v0.6.3...v0.6.4 | ||
[0.6.3]: https://github.com/oscarotero/keep-a-changelog/compare/v0.6.2...v0.6.3 | ||
@@ -119,0 +128,0 @@ [0.6.2]: https://github.com/oscarotero/keep-a-changelog/compare/v0.6.1...v0.6.2 |
@@ -5,3 +5,3 @@ { | ||
"homepage": "https://github.com/oscarotero/keep-a-changelog#readme", | ||
"version": "0.6.3", | ||
"version": "0.6.4", | ||
"main": "src/index.js", | ||
@@ -8,0 +8,0 @@ "bin": { |
# keep-a-changelog | ||
[![Build Status](https://travis-ci.org/oscarotero/keep-a-changelog.svg?branch=master)](https://travis-ci.org/oscarotero/keep-a-changelog) | ||
Node package to parse and generate changelogs following the [keepachangelog](http://keepachangelog.com/en/1.0.0/) format. | ||
@@ -4,0 +6,0 @@ |
const Release = require('./Release'); | ||
const Semver = require('semver'); | ||
@@ -18,3 +19,3 @@ class Changelog { | ||
this.releases.push(release); | ||
this.releases.sort((a, b) => a.compare(b)); | ||
this.sortReleases(); | ||
release.changelog = this; | ||
@@ -25,2 +26,15 @@ | ||
findRelease(version) { | ||
if (!version) { | ||
return this.releases.find(release => !release.version); | ||
} | ||
return this.releases.find( | ||
release => release.version && Semver.eq(release.version, version) | ||
); | ||
} | ||
sortReleases() { | ||
this.releases.sort((a, b) => a.compare(b)); | ||
} | ||
toString() { | ||
@@ -27,0 +41,0 @@ const t = [`# ${this.title}`]; |
@@ -6,5 +6,3 @@ const Semver = require('semver'); | ||
constructor(version, date, description = '') { | ||
if (typeof version === 'string') { | ||
version = new Semver(version); | ||
} | ||
this.setVersion(version); | ||
@@ -15,3 +13,2 @@ if (typeof date === 'string') { | ||
this.version = version; | ||
this.date = date; | ||
@@ -57,2 +54,13 @@ this.description = description; | ||
setVersion(version) { | ||
if (typeof version === 'string') { | ||
version = new Semver(version); | ||
} | ||
this.version = version; | ||
//Re-sort the releases of the parent changelog | ||
if (this.changelog) { | ||
this.changelog.sortReleases(); | ||
} | ||
} | ||
addChange(type, change) { | ||
@@ -59,0 +67,0 @@ if (!(change instanceof Change)) { |
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
78
1
22627
10
474