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

fs: make F_OK/R_OK/W_OK/X_OK not writable #507

Closed
wants to merge 1 commit into from

Conversation

JacksonTian
Copy link
Contributor

change the fs.F_OK/R_OK/W_OK/X_OK out of fs.js will lead unexpect
exception. make these properties readonly.

@rvagg
Copy link
Member

rvagg commented Jan 19, 2015

a description would be nice with pull requests to help justify the change

also, it looks like this might break because F_OK is used elsewhere in fs.js

@JacksonTian JacksonTian changed the title fs: disallow overwrite F_OK/R_OK/W_OK/X_OK fs: make F_OK/R_OK/W_OK/X_OK not writable Jan 19, 2015
@JacksonTian
Copy link
Contributor Author

Updated. @rvagg .

@rvagg
Copy link
Member

rvagg commented Jan 19, 2015

thanks, will leave this open for comment for now

@cjihrig
Copy link
Contributor

cjihrig commented Jan 19, 2015

Why not apply this to any of the other constants in fs.js? And, speaking of constants, could we use some new ES6 goodness to define constants?

@JacksonTian
Copy link
Contributor Author

Other constants in fs.js were not been exported. @cjihrig

@fengmk2
Copy link
Contributor

fengmk2 commented Jan 20, 2015

Use const instead of var will be better.

@JacksonTian
Copy link
Contributor Author

const can make a variable to a constant, but can't make the property be read only.

fs.R_OK = R_OK;
fs.W_OK = W_OK;
fs.X_OK = X_OK;
// don't allow mode to accidentally be overwritten.
Copy link
Member

Choose a reason for hiding this comment

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

Style: please use proper capitalization in comments.

@bnoordhuis
Copy link
Member

I agree with @cjihrig that it's somewhat inconsistent to apply it only to the fs.access() flags.

change the fs.F_OK/R_OK/W_OK/X_OK out of fs.js will lead unexpect
exception. make these properties readonly.
@JacksonTian
Copy link
Contributor Author

@bnoordhuis Updated by your comment. Thanks.

@bnoordhuis
Copy link
Member

LGTM but I defer to @cjihrig.

@cjihrig
Copy link
Contributor

cjihrig commented Jan 21, 2015

I'll land this today.

cjihrig pushed a commit that referenced this pull request Jan 21, 2015
These flags were defined as constants, but could be
overwritten when exported from fs. This commit exports
the flags as read only properties of fs.

PR-URL: #507
Reviewed-By: Ben Noordhuis <[email protected]>
Reviewed-By: Colin Ihrig <[email protected]>
@cjihrig
Copy link
Contributor

cjihrig commented Jan 21, 2015

Thanks! Landed with a slightly reworded commit message in 8b98096.

@cjihrig cjihrig closed this Jan 21, 2015
@ChALkeR ChALkeR added the fs Issues and PRs related to the fs subsystem / file system. label Feb 16, 2016
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
fs Issues and PRs related to the fs subsystem / file system.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

6 participants