Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 12 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,17 @@
# cronbake

## 0.3.1

### Patch Changes

- Fix critical parser bugs in cron expression aliases:
- `@hourly`: Corrected from running every minute to running every hour at minute 0
- `@daily`: Fixed from running every hour to running once daily at midnight
- `@weekly`: Fixed invalid cron expression (had month=0) to run at midnight every Sunday
- `@monthly`: Corrected hour from 1 AM to midnight on the 1st of each month
- `@yearly` & `@annually`: Corrected hour from 1 AM to midnight on January 1st
- `parseOnDayStr`: Fixed parsing logic to correctly handle `@on_<day>` format

## 0.3.0

### Minor Changes
Expand Down
Binary file modified bun.lockb
Binary file not shown.
9 changes: 8 additions & 1 deletion lib/index.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -635,8 +635,15 @@ describe("Cron", () => {
});

it("should get the date of the last execution of the cron job", () => {
const lastExecution = cron.lastExecution();
// Use a frequent cron to avoid timeout in getPrevious() loop
const frequentCron = new Cron({
name: "frequent-test",
cron: "* * * * * *",
callback: jest.fn(),
});
const lastExecution = frequentCron.lastExecution();
expect(lastExecution).toBeInstanceOf(Date);
frequentCron.destroy();
});

it("should get the date of the next execution of the cron job", () => {
Expand Down
4 changes: 2 additions & 2 deletions lib/parser.ts
Original file line number Diff line number Diff line change
Expand Up @@ -76,10 +76,10 @@ class CronParser<T extends string> implements ICronParser {
}

/**
* Parses a string in the format "@on_<day>_<unit>" and returns the corresponding cron expression.
* Parses a string in the format "@on_<day>" and returns the corresponding cron expression.
*/
private parseOnDayStr(str: OnDayStrType): string {
const [, day, _unit] = str.split("_");
const [, day] = str.split("_");
const days = new Map([
["sunday", 0],
["monday", 1],
Expand Down
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
"name": "cronbake",
"description": "A powerful and flexible cron job manager built with TypeScript",
"module": "dist/index.js",
"version": "0.3.0",
"version": "0.3.1",
"publishConfig": {
"access": "public"
},
Expand Down