Skip to content

Instantly share code, notes, and snippets.

@bahamas10
Created February 6, 2015 16:57
Show Gist options
  • Select an option

  • Save bahamas10/a59d8f771e2216275e4a to your computer and use it in GitHub Desktop.

Select an option

Save bahamas10/a59d8f771e2216275e4a to your computer and use it in GitHub Desktop.
nodejs mkdir mode
> fs.mkdirSync('test-dir', 0777)
undefined
> (fs.statSync('test-dir').mode & 0777).toString(8)
'755'
> process.version
'v0.10.33'
@bahamas10

Copy link
Copy Markdown
Author

it works by modifying the umask

> process.umask().toString(8)
'22'
> process.umask(0)
18
> process.umask().toString(8)
'0'

now

> fs.mkdirSync('test-dir2', 0777)
undefined
> (fs.statSync('test-dir2').mode & 0777).toString(8)
'777'

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment