Skip to content

Commit

Permalink
Merge pull request #106 from merencia/v2.0.0
Browse files Browse the repository at this point in the history
V2.0.0
  • Loading branch information
merencia committed Sep 10, 2018
2 parents 3123d7c + 4600cda commit 19d7460
Show file tree
Hide file tree
Showing 48 changed files with 1,888 additions and 479 deletions.
3 changes: 2 additions & 1 deletion .jshintrc
@@ -1,4 +1,5 @@
{
"esversion": 6,
"node": true,
"bitwise": true,
"curly": true,
Expand All @@ -11,7 +12,7 @@
"maxcomplexity": 8,
"maxparams": 4,
"nonbsp": true,
"nonew": true,
"nonew": false,
"quotmark": "single",
"shadow": false,
"strict": true,
Expand Down
5 changes: 4 additions & 1 deletion .travis.yml
@@ -1,7 +1,10 @@
language: node_js
node_js:
- stable
- "8"
before_script:
- export TZ=America/Sao_Paulo
- echo '$TZ' | sudo tee /etc/timezone
- sudo dpkg-reconfigure --frontend noninteractive tzdata
- npm install
script:
- npm run check
48 changes: 34 additions & 14 deletions README.md
Expand Up @@ -26,7 +26,7 @@ Import node-cron and schedule a task:
```javascript
var cron = require('node-cron');

cron.schedule('* * * * *', function(){
cron.schedule('* * * * *', () => {
console.log('running a task every minute');
});
```
Expand Down Expand Up @@ -68,7 +68,7 @@ You may use multiples values separated by comma:
```javascript
var cron = require('node-cron');

cron.schedule('1,2,4,5 * * * *', function(){
cron.schedule('1,2,4,5 * * * *', () => {
console.log('running every minute 1, 2, 4 and 5');
});
```
Expand All @@ -80,7 +80,7 @@ You may also define a range of values:
```javascript
var cron = require('node-cron');

cron.schedule('1-5 * * * *', function(){
cron.schedule('1-5 * * * *', () => {
console.log('running every minute to 1 from 5');
});
```
Expand All @@ -92,7 +92,7 @@ Step values can be used in conjunction with ranges, following a range with '/' a
```javascript
var cron = require('node-cron');

cron.schedule('*/2 * * * *', function(){
cron.schedule('*/2 * * * *', () => {
console.log('running a task every two minutes');
});
```
Expand All @@ -104,7 +104,7 @@ For month and week day you also may use names or short names. e.g:
```javascript
var cron = require('node-cron');

cron.schedule('* * * January,September Sunday', function(){
cron.schedule('* * * January,September Sunday', () => {
console.log('running on Sundays of January and September');
});
```
Expand All @@ -114,7 +114,7 @@ Or with short names:
```javascript
var cron = require('node-cron');

cron.schedule('* * * Jan,Sep Sun', function(){
cron.schedule('* * * Jan,Sep Sun', () => {
console.log('running on Sundays of January and September');
});
```
Expand All @@ -127,9 +127,27 @@ Schedules given task to be executed whenever the cron expression ticks.

Arguments:

- !string expression - Cron expression
- !Function func - Task to be executed
- boolean? immediateStart - Whether to start scheduler immediately after create.
- **expression** `string`: Cron expression
- **function** `Function`: Task to be executed
- **options** `Object`: Optional configuration for job scheduling.

#### Options

- **scheduled**: A `boolean` to set if the created task is schaduled. Default `true`;
- **timezone**: The timezone that is used for job scheduling;

**Example**:

```js
var cron = require('node-cron');

cron.schedule('0 1 * * *', () => {
console.log('Runing a job at 01:00 at America/Sao_Paulo timezone');
}, {
scheduled: true,
timezone: "America/Sao_Paulo"
});
```

## ScheduledTask methods

Expand All @@ -140,9 +158,11 @@ Starts the scheduled task.
```javascript
var cron = require('node-cron');

var task = cron.schedule('* * * * *', function() {
console.log('immediately started');
}, false);
var task = cron.schedule('* * * * *', () => {
console.log('stoped task');
}, {
scheduled: false
});

task.start();
```
Expand All @@ -154,7 +174,7 @@ The task won't be executed unless re-started.
```javascript
var cron = require('node-cron');

var task = cron.schedule('* * * * *', function() {
var task = cron.schedule('* * * * *', () => {
console.log('will execute every minute until stopped');
});

Expand All @@ -168,7 +188,7 @@ The task will be stopped and completely destroyed.
```javascript
var cron = require('node-cron');

var task = cron.schedule('* * * * *', function() {
var task = cron.schedule('* * * * *', () => {
console.log('will not execute anymore, nor be able to restart');
});

Expand Down

0 comments on commit 19d7460

Please sign in to comment.