@@ -211,6 +211,22 @@ function verifyStatObject(stat) {
211211 assert . deepStrictEqual ( list , [ 'baz2.js' , 'dir' ] ) ;
212212 await rmdir ( newdir ) ;
213213
214+ // mkdir when options is number.
215+ {
216+ const dir = path . join ( tmpDir , nextdir ( ) ) ;
217+ await mkdir ( dir , 777 ) ;
218+ stats = await stat ( dir ) ;
219+ assert ( stats . isDirectory ( ) ) ;
220+ }
221+
222+ // mkdir when options is string.
223+ {
224+ const dir = path . join ( tmpDir , nextdir ( ) ) ;
225+ await mkdir ( dir , '777' ) ;
226+ stats = await stat ( dir ) ;
227+ assert ( stats . isDirectory ( ) ) ;
228+ }
229+
214230 // mkdirp when folder does not yet exist.
215231 {
216232 const dir = path . join ( tmpDir , nextdir ( ) , nextdir ( ) ) ;
@@ -250,6 +266,24 @@ function verifyStatObject(stat) {
250266 assert ( stats . isDirectory ( ) ) ;
251267 }
252268
269+ // mkdirp require recursive option to be a boolean.
270+ // Anything else generates an error.
271+ {
272+ const dir = path . join ( tmpDir , nextdir ( ) , nextdir ( ) ) ;
273+ [ '' , 1 , { } , [ ] , null , Symbol ( 'test' ) , ( ) => { } ] . forEach ( ( recursive ) => {
274+ assert . rejects (
275+ // mkdir() expects to get a boolean value for options.recursive.
276+ async ( ) => mkdir ( dir , { recursive } ) ,
277+ {
278+ code : 'ERR_INVALID_ARG_TYPE' ,
279+ name : 'TypeError [ERR_INVALID_ARG_TYPE]' ,
280+ message : 'The "recursive" argument must be of type boolean. ' +
281+ `Received type ${ typeof recursive } `
282+ }
283+ ) ;
284+ } ) ;
285+ }
286+
253287 await mkdtemp ( path . resolve ( tmpDir , 'FOO' ) ) ;
254288 assert . rejects (
255289 // mkdtemp() expects to get a string prefix.
0 commit comments