Skip to content

Commit

Permalink
inc throws an error if version doesn't change.
Browse files Browse the repository at this point in the history
ability to specify both calendar and semantic tags in inc

isValid method added.
  • Loading branch information
muratgozel committed Aug 3, 2022
1 parent 63d64ad commit 456ef7c
Show file tree
Hide file tree
Showing 13 changed files with 1,894 additions and 1,376 deletions.
5 changes: 5 additions & 0 deletions .idea/.gitignore

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

8 changes: 8 additions & 0 deletions .idea/modules.xml

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

12 changes: 12 additions & 0 deletions .idea/node-calver.iml

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

6 changes: 6 additions & 0 deletions .idea/vcs.xml

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

19 changes: 19 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -85,6 +85,7 @@ The third argument is the level of the increment operation. `level` might be one
| minor.[dev,alpha,beta,rc] | composite | Increments the minor tag and adds specified modifier tag. |
| patch.[dev,alpha,beta,rc] | composite | Increments the patch tag and adds specified modifier tag. |

### Increment
Let's make some more updates:
```js
// assuming current date is 2021.01
Expand Down Expand Up @@ -114,6 +115,24 @@ const version = calver.inc(format, '2021.1.2.0', 'patch')
// version = 2021.1.2.1
```

To create an initial version, just leave the version field empty:
```js
const version = calver.inc(format, '', 'calendar') // 2021.1.0.0
```

To increment based on both calendar and semantic tags:
```js
const version = calver.inc('yy.mm.minor', '', 'calendar.minor') // 2021.1.0
const version = calver.inc('yy.mm.minor', '2021.1.0', 'calendar.minor') // 2021.1.1
```

### Validation
Test the input if it is valid against a format:
```js
calver.isValid('yyyy.mm.0w', '2020.6.1') === false // because 0W can't be "1", it should be "01"
calver.isValid('yyyy.mm.minor.patch', '0.0.0.1') === false // because YYYY and MM can't be "0"
```

## Tests
```js
npm run test
Expand Down
Loading

0 comments on commit 456ef7c

Please sign in to comment.