Skip to content

Commit 0dcfba3

Browse files
authored
Merge pull request #5 from FreaKzero/feat/4/multi-months
feat(4): Multiple month Support
2 parents 791515e + bf5d4e8 commit 0dcfba3

7 files changed

Lines changed: 39 additions & 16 deletions

File tree

.github/workflows/develop.yml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -10,9 +10,9 @@ jobs:
1010
runs-on: ubuntu-18.04
1111
steps:
1212
- uses: actions/checkout@v1
13-
13+
1414
- name: install dependencies
1515
run: npm install
16-
16+
1717
- name: Test
1818
run: npm run test

.github/workflows/prtitle.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,4 +12,4 @@ jobs:
1212
steps:
1313
- uses: amannn/action-semantic-pull-request@v1.1.1
1414
env:
15-
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
15+
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}

.github/workflows/publish.yml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@ on:
66

77
jobs:
88
build:
9-
runs-on: ubuntu-latest
9+
runs-on: ubuntu-latest
1010
steps:
1111
- uses: actions/checkout@v2
1212
- uses: actions/setup-node@v2
@@ -21,4 +21,4 @@ jobs:
2121
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
2222
- run: npm publish --access public
2323
env:
24-
NODE_AUTH_TOKEN: ${{secrets.NPM_TOKEN}}
24+
NODE_AUTH_TOKEN: ${{secrets.NPM_TOKEN}}

.releaserc.json

Lines changed: 8 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,5 @@
11
{
2-
"branches": [
3-
"main"
4-
],
2+
"branches": ["main"],
53
"plugins": [
64
[
75
"@semantic-release/commit-analyzer",
@@ -21,9 +19,12 @@
2119
}
2220
}
2321
],
24-
["@semantic-release/npm", {
25-
"npmPublish": false
26-
}],
22+
[
23+
"@semantic-release/npm",
24+
{
25+
"npmPublish": false
26+
}
27+
],
2728
"@semantic-release/github",
2829
[
2930
"@semantic-release/git",
@@ -33,4 +34,4 @@
3334
}
3435
]
3536
]
36-
}
37+
}

index.js

Lines changed: 10 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -52,7 +52,9 @@ const dateParser = (pattern, string) => {
5252
/(jan|feb|mar|apr|may|jun|jul|aug|sep|oct|nov|dec) ([0-9]{1,2})/.exec(
5353
string
5454
);
55-
const mon = /(jan|feb|mar|apr|may|jun|jul|aug|sep|oct|nov|dec)/.exec(string);
55+
const monthMatch = string.match(
56+
/(\d+)? (jan|feb|mar|apr|may|jun|jul|aug|sep|oct|nov|dec)/g
57+
);
5658
const months = [
5759
'',
5860
'jan',
@@ -72,8 +74,13 @@ const dateParser = (pattern, string) => {
7274
if (full) {
7375
pattern[3] = full[2];
7476
pattern[4] = months.indexOf(full[1]);
75-
} else if (mon) {
76-
pattern[4] = months.indexOf(mon[1]);
77+
} else if (monthMatch) {
78+
const mon = monthMatch
79+
.map((i) => months.indexOf(i.trim()))
80+
.sort((a, b) => a - b);
81+
if (mon.length) {
82+
pattern[4] = mon.join(',');
83+
}
7784
}
7885

7986
return pattern;

readme.md

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -48,7 +48,7 @@ You can also write the full words like `on saturday at 9:30`
4848
Examples:
4949

5050
```
51-
on mon tue wed every 15 minutes
51+
on mon tue wed every 15 minutes
5252
in december on mondays and saturdays at 9:30
5353
on mondays at 10:30
5454
```
@@ -57,10 +57,19 @@ on mondays at 10:30
5757

5858
You can either use exact dates like `in dec 9 at 9:30` or only months `in dec at 9:30`
5959
You can also write the full words like `in december at 9:30`
60+
Multiple Months are supported
61+
6062
### Tokens
6163

6264
`jan, feb, mar, apr, may, jun, jul, aug, sep, oct, nov, dec`
6365

66+
Examples:
67+
68+
```
69+
on jan feb mar only mondays tuesdays and saturdays at 9:30
70+
on dec mar apr at 13:37
71+
```
72+
6473
## Times:
6574

6675
Times will get sanitized and seconds are optional, to use times the token _at_ is needed. Timeformat is 24 hours and not AM/PM.

test.js

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -39,6 +39,12 @@ test('at 9:10 every year', '0 10 9 1 1 *');
3939
test('at 9:10 every year on saturdays', '0 10 9 1 1 *');
4040
test('every fri mon wed in oct at 10:30', '0 30 10 * 10 1,3,5');
4141
test('very mondays in december all 15 minutes', '0 */15 * * 12 1');
42+
test('on jan feb mar at 9:30', '0 30 9 * 1,2,3 *');
43+
test(
44+
'on jan feb mar only mondays tuesdays and saturdays at 9:30',
45+
'0 30 9 * 1,2,3 1,2,6'
46+
);
47+
test('on jan feb every 45 minutes', '0 */45 * * 1,2 *');
4248

4349
if (process.env.TESTWATCH) {
4450
process.stdout.write('\u001b[3J\u001b[2J\u001b[1J');

0 commit comments

Comments
 (0)