Skip to content

test: replace fs.accessAsync with common.fileExists #17222

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
wants to merge 1 commit into from
Closed
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 test/parallel/test-npm-install.js
Original file line number Diff line number Diff line change
Expand Up @@ -58,6 +58,6 @@ function handleExit(error, stdout, stderr) {
assert.strictEqual(code, 0, `npm install got error code ${code}`);
assert.strictEqual(signalCode, null, `unexpected signal: ${signalCode}`);
assert.doesNotThrow(function() {
fs.accessSync(`${installDir}/node_modules/package-name`);
common.fileExists(`${installDir}/node_modules/package-name`);
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

common.fileExists() doesn't throw, so assert.doesNotThrow() is redundant. Either leave as is, or assert on the return value from common.fileExists().

Side note: common.fileExists() isn't necessary anymore. It was added when fs.exists() was scheduled for deprecation and removal.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

should is maybe be replaced with fs.exists?

Do you think this PR should be closed? If so should we maybe have @df1 remove some instances of common.fileExists?

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@MylesBorins do you mean fs.stat() or fs.access()?
Since fs.exists() is deprecated.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Sorry for saying fs.exists(), when I meant fs.existsSync(). I'd be +1 to removing common.fileExists() and replacing it with fs.existsSync().

This particular change should either be backed out, or updated to use existsSync() without assert.doesNotThrow().

});
}