-
Notifications
You must be signed in to change notification settings - Fork 7.3k
fs.writeFile and fs.writeFileSync ignores options.mode and always writes with permission '644' #25756
Comments
Just tried with v0.12.7 and I got |
I can reproduce the results in the OP with v0.12.7. (OSX 10.10) |
Yes, I'm able to reproduce this. The documentation even states that the default mode is 666, but when calling writeFileSync without the mode param, the mode will still be set as 644. /cc @joyent/node-tsc |
My workaround was to use Still, I'd like |
I found that this is in fact not an issue, but just how UNIX file permissions are handled. You can change the umask with See nodejs/node#2249 and nodejs/node#1104 for more discussion about this problem. |
Yeah, I suspected that was the case but hadn't investigated. Unfortunately the documentation is not clear on that at all. I'm going to tag this as a documentation fix. If you're up to it, a PR fixing up the docs is always welcome ;-) |
bug reproduced on node v0.10 and v0.12, on both linux and mac with the following code:
var fs = require('fs');
fs.writeFileSync('a00.txt', 'hello', { mode: '666' });
console.log(fs.statSync('a00.txt').mode.toString(8));
// output: 100644
The text was updated successfully, but these errors were encountered: