Skip to content

Commit 835776c

Browse files
authored
Merge pull request #13 from chaqchase/fix/fix-presets
Fix/fix presets
2 parents 2bfa140 + 7078ba9 commit 835776c

File tree

5 files changed

+23
-4
lines changed

5 files changed

+23
-4
lines changed

CHANGELOG.md

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,17 @@
11
# cronbake
22

3+
## 0.3.1
4+
5+
### Patch Changes
6+
7+
- Fix critical parser bugs in cron expression aliases:
8+
- `@hourly`: Corrected from running every minute to running every hour at minute 0
9+
- `@daily`: Fixed from running every hour to running once daily at midnight
10+
- `@weekly`: Fixed invalid cron expression (had month=0) to run at midnight every Sunday
11+
- `@monthly`: Corrected hour from 1 AM to midnight on the 1st of each month
12+
- `@yearly` & `@annually`: Corrected hour from 1 AM to midnight on January 1st
13+
- `parseOnDayStr`: Fixed parsing logic to correctly handle `@on_<day>` format
14+
315
## 0.3.0
416

517
### Minor Changes

bun.lockb

3.1 KB
Binary file not shown.

lib/index.test.ts

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -635,8 +635,15 @@ describe("Cron", () => {
635635
});
636636

637637
it("should get the date of the last execution of the cron job", () => {
638-
const lastExecution = cron.lastExecution();
638+
// Use a frequent cron to avoid timeout in getPrevious() loop
639+
const frequentCron = new Cron({
640+
name: "frequent-test",
641+
cron: "* * * * * *",
642+
callback: jest.fn(),
643+
});
644+
const lastExecution = frequentCron.lastExecution();
639645
expect(lastExecution).toBeInstanceOf(Date);
646+
frequentCron.destroy();
640647
});
641648

642649
it("should get the date of the next execution of the cron job", () => {

lib/parser.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -76,10 +76,10 @@ class CronParser<T extends string> implements ICronParser {
7676
}
7777

7878
/**
79-
* Parses a string in the format "@on_<day>_<unit>" and returns the corresponding cron expression.
79+
* Parses a string in the format "@on_<day>" and returns the corresponding cron expression.
8080
*/
8181
private parseOnDayStr(str: OnDayStrType): string {
82-
const [, day, _unit] = str.split("_");
82+
const [, day] = str.split("_");
8383
const days = new Map([
8484
["sunday", 0],
8585
["monday", 1],

package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
"name": "cronbake",
33
"description": "A powerful and flexible cron job manager built with TypeScript",
44
"module": "dist/index.js",
5-
"version": "0.3.0",
5+
"version": "0.3.1",
66
"publishConfig": {
77
"access": "public"
88
},

0 commit comments

Comments
 (0)