Skip to content

b/c of umask, the default mode for ensureDir is 0777 & (~process.umask()) #651

@qiulang

Description

@qiulang

Because of umask, calling ensureDir/ensureDirSync without fs.chmodSync, the actual mode is not the same as the intended mode. I think it is better to mention this in https://github.com/jprichardson/node-fs-extra/blob/master/docs/ensureDir.md especially for someone who is not familiar with umask.

Besides, I feel it is unnecessary to call this in mkdirs.js because node will take care of that.

  if (mode === undefined) {
    mode = o777 & (~process.umask())
  }

Refer to

  1. Using fs.mkdir() make a directory according the Docs the argument 'mode' defaults to 0o777, but actually it's not. nodejs/node#15092
  2. https://stackoverflow.com/questions/30815154/fs-mkdir-is-creating-the-directory-with-different-permissions-than-those-speci

Metadata

Metadata

Assignees

No one assigned

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions