Skip to content

Commit

Permalink
feat: require Node.js >=10.13
Browse files Browse the repository at this point in the history
BREAKING CHANGE: Require Node.js >= 10.13
  • Loading branch information
pvdlg committed Jan 9, 2020
1 parent c463436 commit c34dbc2
Show file tree
Hide file tree
Showing 4 changed files with 18 additions and 9 deletions.
6 changes: 3 additions & 3 deletions index.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
const {URL, format} = require('url');
const {format} = require('url');
const {find, merge} = require('lodash');
const getStream = require('get-stream');
const intoStream = require('into-stream');
Expand Down Expand Up @@ -31,13 +31,13 @@ async function generateNotes(pluginConfig, context) {
const repositoryUrl = options.repositoryUrl.replace(/\.git$/i, '');
const {parserOpts, writerOpts} = await loadChangelogConfig(pluginConfig, context);

const [match, auth, host, path] = /^(?!.+:\/\/)(?:(.*)@)?(.*?):(.*)$/.exec(repositoryUrl) || [];
const [match, auth, host, path] = /^(?!.+:\/\/)(?:(?<auth>.*)@)?(?<host>.*?):(?<path>.*)$/.exec(repositoryUrl) || [];
let {hostname, port, pathname, protocol} = new URL(
match ? `ssh://${auth ? `${auth}@` : ''}${host}/${path}` : repositoryUrl
);
port = protocol.includes('ssh') ? '' : port;
protocol = protocol && /http[^s]/.test(protocol) ? 'http' : 'https';
const [, owner, repository] = /^\/([^/]+)?\/?(.+)?$/.exec(pathname);
const [, owner, repository] = /^\/(?<owner>[^/]+)?\/?(?<repository>.+)?$/.exec(pathname);

const {issue, commit, referenceActions, issuePrefixes} =
find(HOSTS_CONFIG, conf => conf.hostname === hostname) || HOSTS_CONFIG.default;
Expand Down
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@
"xo": "^0.25.0"
},
"engines": {
"node": ">=8.16"
"node": ">=10.13"
},
"files": [
"lib",
Expand Down
4 changes: 2 additions & 2 deletions test/integration.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -158,7 +158,7 @@ test('Accept a "parseOpts" and "writerOpts" objects as option', async t => {
const changelog = await generateNotes(
{
parserOpts: {
headerPattern: /^%%(.*?)%% (.*)$/,
headerPattern: /^%%(?<tag>.*?)%% (?<message>.*)$/,
headerCorrespondence: ['tag', 'message'],
referenceActions: ['keyword'],
issuePrefixes: ['#', 'JIRA-'],
Expand Down Expand Up @@ -197,7 +197,7 @@ test('Accept a partial "parseOpts" and "writerOpts" objects as option', async t
const changelog = await generateNotes(
{
preset: 'angular',
parserOpts: {headerPattern: /^(\w*)(?:\((.*)\)): (.*)$/},
parserOpts: {headerPattern: /^(?<type>\w*)(?:\((?<scope>.*)\)): (?<subject>.*)$/},
writerOpts: {commitsSort: ['subject', 'scope']},
},
{cwd, options: {repositoryUrl}, lastRelease, nextRelease, commits}
Expand Down
15 changes: 12 additions & 3 deletions test/load-changelog-config.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,10 @@ test('Load "conventional-changelog-angular" by default', async t => {
});

test('Accept a "parserOpts" object as option', async t => {
const customParserOpts = {headerPattern: /^##(.*?)## (.*)$/, headerCorrespondence: ['tag', 'shortDesc']};
const customParserOpts = {
headerPattern: /^##(?<tag>.*?)## (?<shortDesc>.*)$/,
headerCorrespondence: ['tag', 'shortDesc'],
};
const changelogConfig = await loadChangelogConfig({parserOpts: customParserOpts}, {cwd});
const angularChangelogConfig = await require('conventional-changelog-angular');

Expand All @@ -71,7 +74,10 @@ test('Accept a "writerOpts" object as option', async t => {
});

test('Accept a partial "parserOpts" object as option that overwrite a preset', async t => {
const customParserOpts = {headerPattern: /^##(.*?)## (.*)$/, headerCorrespondence: ['tag', 'shortDesc']};
const customParserOpts = {
headerPattern: /^##(?<tag>.*?)## (?<shortDesc>.*)$/,
headerCorrespondence: ['tag', 'shortDesc'],
};
const changelogConfig = await loadChangelogConfig({parserOpts: customParserOpts, preset: 'angular'}, {cwd});
const angularChangelogConfig = await require('conventional-changelog-angular');

Expand All @@ -93,7 +99,10 @@ test('Accept a "writerOpts" object as option that overwrite a preset', async t =
});

test('Accept a partial "parserOpts" object as option that overwrite a config', async t => {
const customParserOpts = {headerPattern: /^##(.*?)## (.*)$/, headerCorrespondence: ['tag', 'shortDesc']};
const customParserOpts = {
headerPattern: /^##(?<tag>.*?)## (?<shortDesc>.*)$/,
headerCorrespondence: ['tag', 'shortDesc'],
};
const changelogConfig = await loadChangelogConfig(
{
parserOpts: customParserOpts,
Expand Down

0 comments on commit c34dbc2

Please sign in to comment.