Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@
"cron-validate": "^1.5.3",
"human-interval": "^2.0.1",
"is-invalid-path": "^0.1.0",
"ms": "^2.1.3",
"ms-tiny": "^1.1.0",
"p-wait-for": "3",
"safe-timers": "^1.1.0"
},
Expand Down
12 changes: 10 additions & 2 deletions src/job-utils.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
const humanInterval = require('human-interval');
const later = require('@breejs/later');
const ms = require('ms');
const ms = require('ms-tiny');

/**
* Returns true if `val` is a string and it's not blank.
Expand Down Expand Up @@ -41,7 +41,15 @@ const getName = (job) => {
*/
const getHumanToMs = (_value) => {
const value = humanInterval(_value);
if (Number.isNaN(value)) return ms(_value);
if (Number.isNaN(value)) {
try {
return ms(_value);
} catch (err) {
throw new Error(
`Value "${_value}" is not parseable as a time interval (see <https://breejs.github.io/later/parsers.html#text> for examples)`
);
}
}
return value;
};

Expand Down