Skip to content
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

test: replace fs.accessSync with common.fileExists #17446

Closed
wants to merge 2 commits into from
Closed
Changes from 1 commit
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
4 changes: 1 addition & 3 deletions test/parallel/test-npm-install.js
Original file line number Diff line number Diff line change
Expand Up @@ -57,7 +57,5 @@ 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`);
});
assert(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.

fs.existsSync() would be a better choice.

Copy link
Member

Choose a reason for hiding this comment

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

This raises the question of whether common.fileExists is very aptly named or not... it uses accessSync under the hood rather than existsSync.

Copy link
Contributor

Choose a reason for hiding this comment

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

I mentioned this somewhere else recently. fs.existsSync() was marked for deprecation a while back, so common.fileExists() was added to take its place in the tests. After enough user outrage feedback, existsSync() was undeprecated. common.fileExists() is now redundant and should be removed #codeandlearn #goodfirstcontribution.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

@cjihrig @apapirovski Thank you for review.
Should I replace common.fileExists with fs.existsSync ?

Copy link
Contributor

Choose a reason for hiding this comment

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

@Leko I would change it.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I got it. I'll update it.

}