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

Switch fs.statSync to fs.accessSync, which is faster #976

Merged
merged 1 commit into from Sep 27, 2016
Merged

Conversation

feross
Copy link
Member

@feross feross commented Sep 27, 2016

With fs.accessSync, we check that the folder is readable/writable by us.

try {
portablePathExists = !!fs.statSync(PORTABLE_PATH)
pathExists = !!fs.accessSync(PORTABLE_PATH, fs.constants.R_OK | fs.constants.W_OK)
Copy link
Contributor

@mathiasvr mathiasvr Sep 27, 2016

Choose a reason for hiding this comment

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

accessSync does not return a value (undefined), so pathExists will be false.

Copy link
Member Author

Choose a reason for hiding this comment

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

Looks like I need to take a deep breath and slow down today... 😊 Will fix.

Copy link
Member Author

Choose a reason for hiding this comment

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

Okay -- it's updated. Thanks for the thorough review, @mathiasvr!

Copy link
Contributor

Choose a reason for hiding this comment

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

I was honestly in doubt myself when reading the docs. It's so strange that the purpose of this method is to throw an error or just do nothing?? 😄

@feross
Copy link
Member Author

feross commented Sep 27, 2016

Just tested on Windows, and everything looks good!

@feross feross merged commit f9bb838 into master Sep 27, 2016
@feross feross deleted the feross/portable branch September 27, 2016 20:59
@lock lock bot locked as resolved and limited conversation to collaborators May 15, 2018
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants