@abtnode/cron 1.15.17 → 1.16.0-beta-b16cb035

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/lib/index.js CHANGED
@@ -19,6 +19,8 @@ function init({ context = {}, jobs = [], onError = () => {} }) {
19
19
  }
20
20
  });
21
21
  }
22
+
23
+ return cron;
22
24
  }
23
25
 
24
26
  module.exports = { init };
package/lib/logger.js CHANGED
@@ -1,9 +1,9 @@
1
- /* eslint-disable no-console */
1
+ const debug = require('debug')(require('../package.json').name);
2
2
 
3
3
  const noop = () => {};
4
- const isTest = process.env.NODE_ENV === 'test';
4
+ const isTest = !!process.env.NODE_ENV && process.env.NODE_ENV.startsWith('test');
5
5
 
6
- module.exports = {
7
- info: isTest ? noop : (...args) => console.log(...args),
8
- error: isTest ? noop : (...args) => console.error(...args),
9
- };
6
+ module.exports = ['error', 'warn', 'info', 'debug', 'verbose', 'silly'].reduce((acc, fn) => {
7
+ acc[fn] = isTest ? noop : debug;
8
+ return acc;
9
+ }, {});
package/lib/scheduler.js CHANGED
@@ -32,11 +32,6 @@ class CronScheduler {
32
32
  async (...args) => {
33
33
  try {
34
34
  logger.info('job started', { name: jobName });
35
- if (fn[Symbol.toStringTag] !== 'AsyncFunction') {
36
- fn(...args);
37
- logger.info('job finished', { name: jobName });
38
- return;
39
- }
40
35
 
41
36
  await fn(...args);
42
37
  logger.info('job finished', { name: jobName });
package/package.json CHANGED
@@ -3,7 +3,7 @@
3
3
  "publishConfig": {
4
4
  "access": "public"
5
5
  },
6
- "version": "1.15.17",
6
+ "version": "1.16.0-beta-b16cb035",
7
7
  "description": "Simple lib to manage crons in ABT Node",
8
8
  "main": "lib/index.js",
9
9
  "files": [
@@ -19,10 +19,11 @@
19
19
  "author": "wangshijun <wangshijun2010@gmail.com> (http://github.com/wangshijun)",
20
20
  "license": "MIT",
21
21
  "dependencies": {
22
- "cron": "^1.8.2"
22
+ "cron": "^2.1.0",
23
+ "debug": "^4.3.4"
23
24
  },
24
25
  "devDependencies": {
25
- "jest": "^27.3.1"
26
+ "jest": "^27.5.1"
26
27
  },
27
- "gitHead": "22715c3ea74d0230f3413162a17f491614b6735a"
28
+ "gitHead": "138bd91aee5a35b28c2de4e1e924c44932efaf3a"
28
29
  }