From dd678110788a298a12c7261464cdd0dee4ff55cf Mon Sep 17 00:00:00 2001 From: Livio Brunner Date: Mon, 5 Oct 2020 23:17:52 +0200 Subject: [PATCH] feat: add support for title option --- README.md | 1 + index.js | 1 + test/integration.test.js | 12 ++++++++++++ 3 files changed, 14 insertions(+) diff --git a/README.md b/README.md index 930a7177..fe75c99f 100644 --- a/README.md +++ b/README.md @@ -65,6 +65,7 @@ With this example: | `commit` | Keyword used to generate commit links (formatted as `////`). See [conventional-changelog-writer#commit](https://github.com/conventional-changelog/conventional-changelog/tree/master/packages/conventional-changelog-writer#commit). | `commits` for Bitbucket repositories, `commit` otherwise | | `issue` | Keyword used to generate issue links (formatted as `////`). See [conventional-changelog-writer#issue](https://github.com/conventional-changelog/conventional-changelog/tree/master/packages/conventional-changelog-writer#issue). | `issue` for Bitbucket repositories, `issues` otherwise | | `presetConfig` | Additional configuration passed to the [conventional-changelog](https://github.com/conventional-changelog/conventional-changelog) preset. Used for example with [conventional-changelog-conventionalcommits](https://github.com/conventional-changelog/conventional-changelog-config-spec/blob/master/versions/2.0.0/README.md). | - | +| `title` | The title of the release. Used for example in the [header template of conventinal-changelog-angular](https://github.com/conventional-changelog/conventional-changelog/blob/master/packages/conventional-changelog-angular/templates/header.hbs) | - | **Notes**: in order to use a `preset` it must be installed (for example to use the [eslint preset](https://github.com/conventional-changelog/conventional-changelog/tree/master/packages/conventional-changelog-eslint) you must install it with `npm install conventional-changelog-eslint -D`) diff --git a/index.js b/index.js index 8cbd5f8f..499ef2a9 100644 --- a/index.js +++ b/index.js @@ -70,6 +70,7 @@ async function generateNotes(pluginConfig, context) { linkCompare: currentTag && previousTag, issue, commit, + title: pluginConfig.title, packageData: ((await readPkgUp({normalize: false, cwd})) || {}).packageJson, }, {host: hostConfig, linkCompare, linkReferences, commit: commitConfig, issue: issueConfig} diff --git a/test/integration.test.js b/test/integration.test.js index c1bd39f4..d5db4149 100644 --- a/test/integration.test.js +++ b/test/integration.test.js @@ -55,6 +55,7 @@ test('Set conventional-changelog-writer context', async t => { issue: 'issues', commit: 'commit', packageData: undefined, + title: undefined, linkReferences: undefined, }); }); @@ -78,6 +79,7 @@ test('Set conventional-changelog-writer context with package.json', async t => { host, owner, repository, + title: undefined, previousTag: lastRelease.gitTag, currentTag: nextRelease.gitTag, linkCompare: lastRelease.gitTag, @@ -554,6 +556,16 @@ test('Accept an "issue" option', async t => { ); }); +test('Accept an "title" option', async t => { + const commits = [{hash: '111', message: 'fix(scope1): First fix\n\nresolve #10'}]; + const changelog = await generateNotes( + {title: 'release-title'}, + {cwd, options: {repositoryUrl: 'https://github.com/owner/repo'}, lastRelease, nextRelease, commits} + ); + + t.regex(changelog, new RegExp(escape('"release-title"'))); +}); + test('Ignore malformatted commits and include valid ones', async t => { const commits = [ {hash: '111', message: 'fix(scope1): First fix'},