bradymholt / cRonstrue

JavaScript library that translates Cron expressions into human readable descriptions
http://bradymholt.github.io/cRonstrue/
MIT License
1.28k stars 168 forks source link

Parsing crontab extensions: Expression has only 1 part. At least 5 parts are required. #277

Closed LittleColin closed 1 year ago

LittleColin commented 1 year ago

Thanks for the library. I encountered an unexpected limitation recently.

crontab extensions cause an exception to be reported: https://man7.org/linux/man-pages/man5/crontab.5.html#EXTENSIONS

   @reboot    :    Run once after reboot.
   @yearly    :    Run once a year, ie.  "0 0 1 1 *".
   @annually  :    Run once a year, ie.  "0 0 1 1 *".
   @monthly   :    Run once a month, ie. "0 0 1 * *".
   @weekly    :    Run once a week, ie.  "0 0 * * 0".
   @daily     :    Run once a day, ie.   "0 0 * * *".
   @hourly    :    Run once an hour, ie. "0 * * * *".
const cronstrue = require("cronstrue");
console.log(cronstrue.toString("@hourly"));

Results in:

cronstruetest/node_modules/cronstrue/dist/cronstrue.js:276
                throw "".concat(ex);
                ^
Error: Expression has only 1 part. At least 5 parts are required.

I was using version 2.23.0 of cronstrue.

bradymholt commented 1 year ago

crontab "nicknames" (ex: @hourly) are not currently supported