diff --git a/CHANGELOG.md b/CHANGELOG.md index d8a9ab1..31b465a 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -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_` format + ## 0.3.0 ### Minor Changes diff --git a/bun.lockb b/bun.lockb index c810a47..718ad42 100755 Binary files a/bun.lockb and b/bun.lockb differ diff --git a/lib/index.test.ts b/lib/index.test.ts index b5b9a1a..2f9ec1f 100644 --- a/lib/index.test.ts +++ b/lib/index.test.ts @@ -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", () => { diff --git a/lib/parser.ts b/lib/parser.ts index 962ec69..d7f7186 100644 --- a/lib/parser.ts +++ b/lib/parser.ts @@ -76,10 +76,10 @@ class CronParser implements ICronParser { } /** - * Parses a string in the format "@on__" and returns the corresponding cron expression. + * Parses a string in the format "@on_" 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], diff --git a/package.json b/package.json index e1f9013..89ff513 100644 --- a/package.json +++ b/package.json @@ -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" },