Skip to content

"fs.writeFile" with mode 0o777 doesn't work as expected #1104

Closed
@ysmood

Description

@ysmood

Sample code:

var fs;

fs = require('fs');

try {
  fs.unlinkSync('a');
} catch (_error) {}

fs.writeFileSync('a', 'ok', {
  mode: 0o777
});
console.log(fs.statSync('a').mode.toString(8));
// output => 0o755

fs.chmodSync('a', 0o777);
console.log(fs.statSync('a').mode.toString(8));
// output => 0o777

It should output 0o777. But I get 0o755.
If I use the fs.chmod to change mode, everything will go well.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions