@@ -17,6 +17,7 @@ var YAML = require('js-yaml');
17
17
var rimraf = require ( 'rimraf' ) ;
18
18
var iconv = require ( 'iconv-lite' ) ;
19
19
var pathIsAbsolute = require ( 'path-is-absolute' ) ;
20
+ var mkdirp = require ( 'mkdirp' ) . sync ;
20
21
21
22
// Windows?
22
23
var win32 = process . platform === 'win32' ;
@@ -180,22 +181,11 @@ file.expandMapping = function(patterns, destBase, options) {
180
181
// Like mkdir -p. Create a directory and any intermediary directories.
181
182
file . mkdir = function ( dirpath , mode ) {
182
183
if ( grunt . option ( 'no-write' ) ) { return ; }
183
- // Set directory mode in a strict-mode-friendly way.
184
- if ( mode == null ) {
185
- mode = parseInt ( '0777' , 8 ) & ( ~ process . umask ( ) ) ;
184
+ try {
185
+ mkdirp ( dirpath , { mode : mode } ) ;
186
+ } catch ( e ) {
187
+ throw grunt . util . error ( 'Unable to create directory "' + dirpath + '" (Error code: ' + e . code + ').' , e ) ;
186
188
}
187
- dirpath . split ( pathSeparatorRe ) . reduce ( function ( parts , part ) {
188
- parts += part + '/' ;
189
- var subpath = path . resolve ( parts ) ;
190
- if ( ! file . exists ( subpath ) ) {
191
- try {
192
- fs . mkdirSync ( subpath , mode ) ;
193
- } catch ( e ) {
194
- throw grunt . util . error ( 'Unable to create directory "' + subpath + '" (Error code: ' + e . code + ').' , e ) ;
195
- }
196
- }
197
- return parts ;
198
- } , '' ) ;
199
189
} ;
200
190
201
191
// Recurse into a directory, executing callback for each file.
0 commit comments