Skip to content

Commit

Permalink
fs: remove redundant nullCheck
Browse files Browse the repository at this point in the history
PR-URL: #48826
Reviewed-By: Luigi Pinca <luigipinca@gmail.com>
Reviewed-By: Mohammed Keyvanzadeh <mohammadkeyvanzade94@gmail.com>
Reviewed-By: Yagiz Nizipli <yagiz@nizipli.com>
  • Loading branch information
LiviaMedeiros authored and targos committed Nov 26, 2023
1 parent 97d8749 commit ae8bb16
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 4 deletions.
5 changes: 1 addition & 4 deletions lib/fs.js
Original file line number Diff line number Diff line change
Expand Up @@ -104,7 +104,6 @@ const {
getValidatedPath,
getValidMode,
handleErrorFromBinding,
nullCheck,
preprocessSymlinkDestination,
Stats,
getStatFsFromBinding,
Expand Down Expand Up @@ -1398,14 +1397,12 @@ function mkdirSync(path, options) {
/**
* An iterative algorithm for reading the entire contents of the `basePath` directory.
* This function does not validate `basePath` as a directory. It is passed directly to
* `binding.readdir` after a `nullCheck`.
* `binding.readdir`.
* @param {string} basePath
* @param {{ encoding: string, withFileTypes: boolean }} options
* @returns {string[] | Dirent[]}
*/
function readdirSyncRecursive(basePath, options) {
nullCheck(basePath, 'path', true);

const withFileTypes = Boolean(options.withFileTypes);
const encoding = options.encoding;

Expand Down
3 changes: 3 additions & 0 deletions test/parallel/test-fs-null-bytes.js
Original file line number Diff line number Diff line change
Expand Up @@ -66,6 +66,7 @@ check(fs.mkdir, fs.mkdirSync, 'foo\u0000bar', '0755');
check(fs.open, fs.openSync, 'foo\u0000bar', 'r');
check(fs.readFile, fs.readFileSync, 'foo\u0000bar');
check(fs.readdir, fs.readdirSync, 'foo\u0000bar');
check(fs.readdir, fs.readdirSync, 'foo\u0000bar', { recursive: true });
check(fs.readlink, fs.readlinkSync, 'foo\u0000bar');
check(fs.realpath, fs.realpathSync, 'foo\u0000bar');
check(fs.rename, fs.renameSync, 'foo\u0000bar', 'foobar');
Expand Down Expand Up @@ -100,6 +101,7 @@ check(fs.mkdir, fs.mkdirSync, fileUrl, '0755');
check(fs.open, fs.openSync, fileUrl, 'r');
check(fs.readFile, fs.readFileSync, fileUrl);
check(fs.readdir, fs.readdirSync, fileUrl);
check(fs.readdir, fs.readdirSync, fileUrl, { recursive: true });
check(fs.readlink, fs.readlinkSync, fileUrl);
check(fs.realpath, fs.realpathSync, fileUrl);
check(fs.rename, fs.renameSync, fileUrl, 'foobar');
Expand Down Expand Up @@ -131,6 +133,7 @@ check(fs.mkdir, fs.mkdirSync, fileUrl2, '0755');
check(fs.open, fs.openSync, fileUrl2, 'r');
check(fs.readFile, fs.readFileSync, fileUrl2);
check(fs.readdir, fs.readdirSync, fileUrl2);
check(fs.readdir, fs.readdirSync, fileUrl2, { recursive: true });
check(fs.readlink, fs.readlinkSync, fileUrl2);
check(fs.realpath, fs.realpathSync, fileUrl2);
check(fs.rename, fs.renameSync, fileUrl2, 'foobar');
Expand Down

0 comments on commit ae8bb16

Please sign in to comment.