Skip to content

Commit a16fae0

Browse files
committed
Add runOnInit control.
1 parent ef6d5de commit a16fae0

File tree

3 files changed

+15
-5
lines changed

3 files changed

+15
-5
lines changed

dist/cjs.js

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff 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;

dist/esm.mjs

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff 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;

package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
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": {

0 commit comments

Comments
 (0)