Skip to content

Commit

Permalink
Support for workers
Browse files Browse the repository at this point in the history
  • Loading branch information
PonomareVlad committed Nov 5, 2023
1 parent fa94e7f commit ef7a742
Show file tree
Hide file tree
Showing 6 changed files with 34 additions and 22 deletions.
18 changes: 0 additions & 18 deletions lib/parser.js
Original file line number Diff line number Diff line change
Expand Up @@ -95,22 +95,4 @@ CronParser.parseString = function parseString (data) {
return response;
};

/**
* Parse crontab file
*
* @public
* @param {String} filePath Path to file
* @param {Function} callback
*/
CronParser.parseFile = function parseFile (filePath, callback) {
require('fs').readFile(filePath, function(err, data) {
if (err) {
callback(err);
return;
}

return callback(null, CronParser.parseString(data.toString()));
});
};

module.exports = CronParser;
23 changes: 23 additions & 0 deletions lib/parser.node.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
'use strict';

var CronParser = require('./parser');

/**
* Parse crontab file
*
* @public
* @param {String} filePath Path to file
* @param {Function} callback
*/
CronParser.parseFile = function parseFile (filePath, callback) {
require('fs').readFile(filePath, function(err, data) {
if (err) {
callback(err);
return;
}

return callback(null, CronParser.parseString(data.toString()));
});
};

module.exports = CronParser;
9 changes: 8 additions & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@
"name": "cron-parser",
"version": "4.9.0",
"description": "Node.js library for parsing crontab instructions",
"main": "lib/parser.js",
"types": "types/index.d.ts",
"typesVersions": {
"<4.1": {
Expand All @@ -14,6 +13,14 @@
"directories": {
"test": "test"
},
"exports": {
".": {
"types": "./types/index.d.ts",
"worker": "./lib/parser.js",
"browser": "./lib/parser.js",
"default": "./lib/parser.node.js"
}
},
"scripts": {
"test:tsd": "tsd",
"test:unit": "TZ=UTC tap ./test/*.js",
Expand Down
2 changes: 1 addition & 1 deletion test/parser.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
var test = require('tap').test;
var CronParser = require('../lib/parser');
var CronParser = require('../lib/parser.node');

// Globals

Expand Down
2 changes: 1 addition & 1 deletion test/parser_day_of_month.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
var test = require('tap').test;
var CronParser = require('../lib/parser');
var CronParser = require('../lib/parser.node');

test('parse cron with last day in a month', function(t) {
var options = {
Expand Down
2 changes: 1 addition & 1 deletion test/stringify.js
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
'use strict';

var test = require('tap').test;
var CronParser = require('../lib/parser');
var CronParser = require('../lib/parser.node');

test('stringify cron expression all stars no seconds', function (t) {
try {
Expand Down

0 comments on commit ef7a742

Please sign in to comment.