@@ -262,4 +262,57 @@ describe('mkdirp', function() {
262262 } ) ;
263263 } ) ;
264264 } ) ;
265+
266+ it ( 'surfaces mkdir errors that happening during recursion' , function ( done ) {
267+
268+ var ogMkdir = fs . mkdir ;
269+
270+ var spy = expect . spyOn ( fs , 'mkdir' ) . andCall ( function ( dirpath , mode , cb ) {
271+ if ( spy . calls . length === 1 ) {
272+ return ogMkdir ( dirpath , mode , cb ) ;
273+ }
274+ cb ( new Error ( 'boom' ) ) ;
275+ } ) ;
276+
277+ mkdirp ( outputNestedDirpath , function ( err ) {
278+ expect ( err ) . toExist ( ) ;
279+
280+ done ( ) ;
281+ } ) ;
282+ } ) ;
283+
284+ it ( 'surfaces fs.stat errors' , function ( done ) {
285+
286+ expect . spyOn ( fs , 'stat' ) . andCall ( function ( dirpath , cb ) {
287+ cb ( new Error ( 'boom' ) ) ;
288+ } ) ;
289+
290+ mkdirp ( outputDirpath , function ( err ) {
291+ expect ( err ) . toExist ( ) ;
292+
293+ done ( ) ;
294+ } ) ;
295+ } ) ;
296+
297+ it ( 'does not attempt fs.chmod if custom mode matches mode on disk' , function ( done ) {
298+ if ( isWindows ) {
299+ this . skip ( ) ;
300+ return ;
301+ }
302+
303+ var mode = applyUmask ( '700' ) ;
304+
305+ mkdirp ( outputDirpath , mode , function ( err ) {
306+ expect ( err ) . toNotExist ( ) ;
307+
308+ var spy = expect . spyOn ( fs , 'chmod' ) . andCallThrough ( ) ;
309+
310+ mkdirp ( outputDirpath , mode , function ( err ) {
311+ expect ( err ) . toNotExist ( ) ;
312+ expect ( spy . calls . length ) . toEqual ( 0 ) ;
313+
314+ done ( ) ;
315+ } ) ;
316+ } ) ;
317+ } ) ;
265318} ) ;
0 commit comments