Skip to content

Commit a15d91c

Browse files
committed
chore: replace is-valid path dependency with is-invalid-path
is-valid-path is literally just `isInvalidPath(value) === false`, so we can use is-invalid-path directly and skip one unnecessary dependency.
1 parent 05338ce commit a15d91c

File tree

4 files changed

+9
-9
lines changed

4 files changed

+9
-9
lines changed

package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@
1616
"combine-errors": "^3.0.3",
1717
"cron-validate": "^1.4.5",
1818
"human-interval": "^2.0.1",
19-
"is-valid-path": "^0.1.1",
19+
"is-invalid-path": "^0.1.0",
2020
"ms": "^2.1.3",
2121
"p-wait-for": "3",
2222
"safe-timers": "^1.1.0"

src/index.js

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@ const { Worker } = require('node:worker_threads');
99
const { join, resolve } = require('node:path');
1010
const { debuglog } = require('node:util');
1111
const combineErrors = require('combine-errors');
12-
const isValidPath = require('is-valid-path');
12+
const isInvalidPath = require('is-invalid-path');
1313
const later = require('@breejs/later');
1414
const pWaitFor = require('p-wait-for');
1515
const { setTimeout, setInterval } = require('safe-timers');
@@ -203,7 +203,7 @@ class Bree extends EventEmitter {
203203
// <https://nodejs.org/api/esm.html#esm_mandatory_file_extensions>
204204
if (
205205
isSANB(this.config.root) /* istanbul ignore next */ &&
206-
isValidPath(this.config.root)
206+
!isInvalidPath(this.config.root)
207207
) {
208208
const stats = await fs.promises.stat(this.config.root);
209209
if (!stats.isDirectory()) {

src/job-builder.js

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
const { join } = require('node:path');
2-
const isValidPath = require('is-valid-path');
2+
const isInvalidPath = require('is-invalid-path');
33
const later = require('@breejs/later');
44
const { isSANB, isSchedule, parseValue, getJobPath } = require('./job-utils');
55

@@ -64,14 +64,14 @@ const buildJob = (job, config) => {
6464
)
6565
);
6666

67-
if (isValidPath(path)) {
68-
job.path = path;
69-
} else {
67+
if (isInvalidPath(path)) {
7068
// Assume that it's a transformed eval string
7169
job.worker = {
7270
eval: true,
7371
...job.worker
7472
};
73+
} else {
74+
job.path = path;
7575
}
7676
}
7777

src/job-validator.js

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@ const fs = require('node:fs');
22
const { join } = require('node:path');
33
const combineErrors = require('combine-errors');
44
const cron = require('cron-validate');
5-
const isValidPath = require('is-valid-path');
5+
const isInvalidPath = require('is-invalid-path');
66
const {
77
getName,
88
isSANB,
@@ -94,7 +94,7 @@ const validateJobPath = async (job, prefix, config) => {
9494
config.defaultExtension
9595
)
9696
);
97-
if (isValidPath(path)) {
97+
if (!isInvalidPath(path)) {
9898
try {
9999
const stats = await fs.promises.stat(path);
100100
if (!stats.isFile()) {

0 commit comments

Comments
 (0)