File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -6,7 +6,7 @@ declare namespace makeDir {
66 /**
77 Directory [permissions](https://x-team.com/blog/file-system-permissions-umask-node-js/).
88
9- @default 0o777 & (~process.umask())
9+ @default 0o777
1010 */
1111 readonly mode ?: number ;
1212
Original file line number Diff line number Diff line change @@ -23,7 +23,7 @@ const checkPath = pth => {
2323const processOptions = options => {
2424 // https://github.com/sindresorhus/make-dir/issues/18
2525 const defaults = {
26- mode : 0o777 & ( ~ process . umask ( ) ) ,
26+ mode : 0o777 ,
2727 fs
2828 } ;
2929
Original file line number Diff line number Diff line change @@ -90,7 +90,7 @@ Type: `object`
9090##### mode
9191
9292Type: ` integer ` \
93- Default: ` 0o777 & (~process.umask()) `
93+ Default: ` 0o777 `
9494
9595Directory [ permissions] ( https://x-team.com/blog/file-system-permissions-umask-node-js/ ) .
9696
Original file line number Diff line number Diff line change @@ -5,7 +5,19 @@ import pathType from 'path-type';
55
66export const getFixture = ( ) => path . join ( tempy . directory ( ) , 'a/b/c/unicorn_unicorn_unicorn/d/e/f/g/h' ) ;
77
8- export const assertDirectory = ( t , directory , mode = 0o777 & ( ~ process . umask ( ) ) ) => {
8+ let lastMask = 0 ;
9+
10+ function umask ( ) {
11+ // Avoid deprecation warning in v14+
12+ lastMask = process . umask ( lastMask ) ;
13+ process . umask ( lastMask ) ;
14+ return lastMask ;
15+ }
16+
17+ // Get the initial value before any async operations start
18+ umask ( ) ;
19+
20+ export const assertDirectory = ( t , directory , mode = 0o777 & ( ~ umask ( ) ) ) => {
921 // Setting `mode` on `fs.mkdir` on Windows doesn't seem to work
1022 if ( process . platform === 'win32' ) {
1123 mode = 0o666 ;
Original file line number Diff line number Diff line change @@ -2,18 +2,19 @@ import test from 'ava';
22import { getFixture , assertDirectory } from './helpers/util' ;
33import makeDir from '..' ;
44
5+ const mask = 0 ;
56test . before ( ( ) => {
6- process . umask ( 0 ) ;
7+ process . umask ( mask ) ;
78} ) ;
89
910test ( 'async' , async t => {
1011 const dir = getFixture ( ) ;
1112 await makeDir ( dir ) ;
12- assertDirectory ( t , dir , 0o777 & ( ~ process . umask ( ) ) ) ;
13+ assertDirectory ( t , dir , 0o777 & ( ~ mask ) ) ;
1314} ) ;
1415
1516test ( 'sync' , t => {
1617 const dir = getFixture ( ) ;
1718 makeDir . sync ( dir ) ;
18- assertDirectory ( t , dir , 0o777 & ( ~ process . umask ( ) ) ) ;
19+ assertDirectory ( t , dir , 0o777 & ( ~ mask ) ) ;
1920} ) ;
You can’t perform that action at this time.
0 commit comments