Skip to content

Commit

Permalink
Merge 2d47604 into 4980ecc
Browse files Browse the repository at this point in the history
  • Loading branch information
lo1tuma committed Sep 27, 2020
2 parents 4980ecc + 2d47604 commit 864754e
Show file tree
Hide file tree
Showing 5 changed files with 13 additions and 65 deletions.
4 changes: 2 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -94,11 +94,11 @@ If you want to use a custom date format you can configure `pr-log.dateFormat` in

```json
{
"pr-log": { "dateFormat": "DD.MM.YYYY" }
"pr-log": { "dateFormat": "dd.MM.yyyy" }
}
```

Please refer to the [moment.js documentation](https://momentjs.com/docs/#/displaying/format/) for details about the format tokens.
Please refer to the [`dates-fn` documentation](https://date-fns.org/docs/format) for details about the format expressions.

## Usage

Expand Down
7 changes: 4 additions & 3 deletions lib/createChangelog.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
import moment from 'moment';
import { format as formatDate } from 'date-fns';
import { enLocale } from 'date-fns/locale/en-US';
import R from 'ramda';

function formatLinkToPullRequest(pullRequestId, repo) {
Expand All @@ -18,12 +19,12 @@ function formatSection(displayLabel, pullRequests, repo) {
}

export default ({ getCurrentDate, packageInfo }) => {
const defaultDateFormat = 'MMMM D, YYYY';
const defaultDateFormat = 'MMMM d, yyyy';
const { dateFormat = defaultDateFormat } = packageInfo['pr-log'] || {};

return function createChangelog(newVersionNumber, validLabels, mergedPullRequests, repo) {
const groupedPullRequests = R.groupBy(R.prop('label'), mergedPullRequests);
const date = moment(getCurrentDate()).locale('en').format(dateFormat);
const date = formatDate(getCurrentDate(), dateFormat, { locale: enLocale });
const title = `## ${newVersionNumber} (${date})`;

let changelog = `${title}\n\n`;
Expand Down
63 changes: 5 additions & 58 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -20,9 +20,9 @@
"dependencies": {
"@octokit/rest": "18.0.6",
"commander": "6.1.0",
"date-fns": "^2.16.1",
"git-promise": "1.0.0",
"git-url-parse": "11.2.0",
"moment": "2.29.0",
"parse-github-repo-url": "1.4.1",
"prepend": "1.0.2",
"ramda": "0.27.1",
Expand Down
2 changes: 1 addition & 1 deletion test/unit/lib/createChangelogSpec.js
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ test('contains a title with the version number and the formatted date', (t) => {
});

test('format the date with a custom date format', (t) => {
const packageInfo = { 'pr-log': { dateFormat: 'DD.MM.YYYY' } };
const packageInfo = { 'pr-log': { dateFormat: 'dd.MM.yyyy' } };
const createChangelog = createChangelogFactory({ getCurrentDate: () => new Date(0), packageInfo });
const changelog = createChangelog('1.0.0', defaultValidLabels, []);
const expectedTitle = '## 1.0.0 (01.01.1970)';
Expand Down

0 comments on commit 864754e

Please sign in to comment.