Skip to content

Commit 3a401b8

Browse files
cjihrigMylesBorins
authored andcommitted
fs: update rm/rmdir validation messages
The validation code for the rm/rmdir functions treated the options as distinct parameters instead of the options properties that they are. This commit updates the validation to treat them like properties. PR-URL: #35565 Reviewed-By: Ben Coe <[email protected]> Reviewed-By: Luigi Pinca <[email protected]> Reviewed-By: Denys Otrishko <[email protected]> Reviewed-By: Rich Trott <[email protected]> Reviewed-By: Masashi Hirano <[email protected]>
1 parent 937fa5d commit 3a401b8

File tree

3 files changed

+12
-12
lines changed

3 files changed

+12
-12
lines changed

lib/internal/fs/utils.js

+5-5
Original file line numberDiff line numberDiff line change
@@ -675,7 +675,7 @@ const defaultRmdirOptions = {
675675
const validateRmOptions = hideStackFrames((path, options, callback) => {
676676
try {
677677
options = validateRmdirOptions(options, defaultRmOptions);
678-
validateBoolean(options.force, 'force');
678+
validateBoolean(options.force, 'options.force');
679679
} catch (err) {
680680
return callback(err);
681681
}
@@ -703,7 +703,7 @@ const validateRmOptions = hideStackFrames((path, options, callback) => {
703703

704704
const validateRmOptionsSync = hideStackFrames((path, options) => {
705705
options = validateRmdirOptions(options, defaultRmOptions);
706-
validateBoolean(options.force, 'force');
706+
validateBoolean(options.force, 'options.force');
707707

708708
try {
709709
const stats = lazyLoadFs().statSync(path);
@@ -737,9 +737,9 @@ const validateRmdirOptions = hideStackFrames(
737737

738738
options = { ...defaults, ...options };
739739

740-
validateBoolean(options.recursive, 'recursive');
741-
validateInt32(options.retryDelay, 'retryDelay', 0);
742-
validateUint32(options.maxRetries, 'maxRetries');
740+
validateBoolean(options.recursive, 'options.recursive');
741+
validateInt32(options.retryDelay, 'options.retryDelay', 0);
742+
validateUint32(options.maxRetries, 'options.maxRetries');
743743

744744
return options;
745745
});

test/parallel/test-fs-rm.js

+4-4
Original file line numberDiff line numberDiff line change
@@ -251,7 +251,7 @@ function removeAsync(dir) {
251251
}, {
252252
code: 'ERR_INVALID_ARG_TYPE',
253253
name: 'TypeError',
254-
message: /^The "recursive" argument must be of type boolean\./
254+
message: /^The "options\.recursive" property must be of type boolean\./
255255
});
256256
});
257257

@@ -261,7 +261,7 @@ function removeAsync(dir) {
261261
}, {
262262
code: 'ERR_INVALID_ARG_TYPE',
263263
name: 'TypeError',
264-
message: /^The "force" argument must be of type boolean\./
264+
message: /^The "options\.force" property must be of type boolean\./
265265
});
266266
});
267267

@@ -270,14 +270,14 @@ function removeAsync(dir) {
270270
}, {
271271
code: 'ERR_OUT_OF_RANGE',
272272
name: 'RangeError',
273-
message: /^The value of "retryDelay" is out of range\./
273+
message: /^The value of "options\.retryDelay" is out of range\./
274274
});
275275

276276
assert.throws(() => {
277277
validateRmOptionsSync(filePath, { maxRetries: -1 });
278278
}, {
279279
code: 'ERR_OUT_OF_RANGE',
280280
name: 'RangeError',
281-
message: /^The value of "maxRetries" is out of range\./
281+
message: /^The value of "options\.maxRetries" is out of range\./
282282
});
283283
}

test/parallel/test-fs-rmdir-recursive.js

+3-3
Original file line numberDiff line numberDiff line change
@@ -191,7 +191,7 @@ function removeAsync(dir) {
191191
}, {
192192
code: 'ERR_INVALID_ARG_TYPE',
193193
name: 'TypeError',
194-
message: /^The "recursive" argument must be of type boolean\./
194+
message: /^The "options\.recursive" property must be of type boolean\./
195195
});
196196
});
197197

@@ -200,14 +200,14 @@ function removeAsync(dir) {
200200
}, {
201201
code: 'ERR_OUT_OF_RANGE',
202202
name: 'RangeError',
203-
message: /^The value of "retryDelay" is out of range\./
203+
message: /^The value of "options\.retryDelay" is out of range\./
204204
});
205205

206206
assert.throws(() => {
207207
validateRmdirOptions({ maxRetries: -1 });
208208
}, {
209209
code: 'ERR_OUT_OF_RANGE',
210210
name: 'RangeError',
211-
message: /^The value of "maxRetries" is out of range\./
211+
message: /^The value of "options\.maxRetries" is out of range\./
212212
});
213213
}

0 commit comments

Comments
 (0)