File tree Expand file tree Collapse file tree 3 files changed +15
-5
lines changed Expand file tree Collapse file tree 3 files changed +15
-5
lines changed Original file line number Diff line number Diff line change @@ -41,9 +41,14 @@ class Task {
4141 * Create a CRON job to run the task on a schedule.
4242 * @param {string } time The CRON time by which to execute. Defaults to every five minutes.
4343 * @param {string } timeZone The (optional) timezone in which to operate the job.
44+ * @param {boolean } runOnInit Whether to run the job immediately upon scheduling. Defaults to true.
4445 * @returns The newly created job.
4546 */
46- schedule = ( time = "*/5 * * * *" , timeZone = "default" ) => {
47+ schedule = (
48+ time = "*/5 * * * *" ,
49+ timeZone = "default" ,
50+ runOnInit = true
51+ ) => {
4752 try {
4853 const job = new CronJob (
4954 time ,
@@ -52,7 +57,7 @@ class Task {
5257 true ,
5358 timeZone ,
5459 this ,
55- true
60+ runOnInit
5661 ) ;
5762
5863 return job ;
Original file line number Diff line number Diff line change @@ -41,9 +41,14 @@ export class Task {
4141 * Create a CRON job to run the task on a schedule.
4242 * @param {string } time The CRON time by which to execute. Defaults to every five minutes.
4343 * @param {string } timeZone The (optional) timezone in which to operate the job.
44+ * @param {boolean } runOnInit Whether to run the job immediately upon scheduling. Defaults to true.
4445 * @returns The newly created job.
4546 */
46- schedule = ( time = "*/5 * * * *" , timeZone = "default" ) => {
47+ schedule = (
48+ time = "*/5 * * * *" ,
49+ timeZone = "default" ,
50+ runOnInit = true
51+ ) => {
4752 try {
4853 const job = new CronJob (
4954 time ,
@@ -52,7 +57,7 @@ export class Task {
5257 true ,
5358 timeZone ,
5459 this ,
55- true
60+ runOnInit
5661 ) ;
5762
5863 return job ;
Original file line number Diff line number Diff line change 11{
22 "name" : " @nottimtam/taskman.js" ,
3- "version" : " 1.1.42 " ,
3+ "version" : " 1.1.43 " ,
44 "description" : " CRON-scheduled asynchronous task manager." ,
55 "main" : " dist/cjs.js" ,
66 "exports" : {
You can’t perform that action at this time.
0 commit comments