@tryghost/job-manager 0.8.7 → 0.8.11

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.
@@ -3,7 +3,7 @@ const fastq = require('fastq');
3
3
  const later = require('@breejs/later');
4
4
  const Bree = require('bree');
5
5
  const pWaitFor = require('p-wait-for');
6
- const errors = require('@tryghost/errors');
6
+ const {IgnitionError, IncorrectUsageError} = require('@tryghost/errors');
7
7
  const isCronExpression = require('./is-cron-expression');
8
8
  const assembleBreeJob = require('./assemble-bree-job');
9
9
 
@@ -67,7 +67,9 @@ class JobManager {
67
67
  if (typeof job === 'string') {
68
68
  name = path.parse(job).name;
69
69
  } else {
70
- throw new Error('Name parameter should be present if job is a function');
70
+ throw new IncorrectUsageError({
71
+ message: 'Name parameter should be present if job is a function'
72
+ });
71
73
  }
72
74
  }
73
75
 
@@ -79,7 +81,9 @@ class JobManager {
79
81
  }
80
82
 
81
83
  if ((schedule.error && schedule.error !== -1) || schedule.schedules.length === 0) {
82
- throw new Error('Invalid schedule format');
84
+ throw new IncorrectUsageError({
85
+ message: 'Invalid schedule format'
86
+ });
83
87
  }
84
88
 
85
89
  this.logging.info(`Scheduling job ${name} at ${at}. Next run on: ${later.schedule(schedule).next()}`);
@@ -105,7 +109,7 @@ class JobManager {
105
109
  } catch (err) {
106
110
  // NOTE: each job should be written in a safe way and handle all errors internally
107
111
  // if the error is caught here jobs implementaton should be changed
108
- this.logging.error(new errors.IgnitionError({
112
+ this.logging.error(new IgnitionError({
109
113
  level: 'critical',
110
114
  errorType: 'UnhandledJobError',
111
115
  message: 'Processed job threw an unhandled error',
package/package.json CHANGED
@@ -1,13 +1,13 @@
1
1
  {
2
2
  "name": "@tryghost/job-manager",
3
- "version": "0.8.7",
4
- "repository": "https://github.com/TryGhost/Utils/tree/master/packages/job-manager",
3
+ "version": "0.8.11",
4
+ "repository": "https://github.com/TryGhost/Utils/tree/main/packages/job-manager",
5
5
  "author": "Ghost Foundation",
6
6
  "license": "MIT",
7
7
  "main": "index.js",
8
8
  "scripts": {
9
9
  "dev": "echo \"Implement me!\"",
10
- "test": "NODE_ENV=testing mocha './test/**/*.test.js'",
10
+ "test": "NODE_ENV=testing c8 --reporter text --reporter cobertura mocha './test/**/*.test.js'",
11
11
  "lint": "eslint . --ext .js --cache",
12
12
  "posttest": "yarn lint"
13
13
  },
@@ -19,12 +19,13 @@
19
19
  "access": "public"
20
20
  },
21
21
  "devDependencies": {
22
- "@sinonjs/fake-timers": "7.1.2",
23
- "date-fns": "2.22.1",
22
+ "@sinonjs/fake-timers": "8.0.1",
23
+ "c8": "7.10.0",
24
+ "date-fns": "2.25.0",
24
25
  "delay": "5.0.0",
25
- "mocha": "9.0.0",
26
+ "mocha": "9.1.3",
26
27
  "should": "13.2.3",
27
- "sinon": "11.0.0"
28
+ "sinon": "11.1.2"
28
29
  },
29
30
  "dependencies": {
30
31
  "@breejs/later": "^4.0.2",
@@ -33,5 +34,5 @@
33
34
  "fastq": "^1.11.0",
34
35
  "p-wait-for": "^3.2.0"
35
36
  },
36
- "gitHead": "58aee93218b7cb98a75216704f0568cf1025231a"
37
+ "gitHead": "6f0646450de6e72d3542812ed028f71cd7e38ccf"
37
38
  }