@@ -13,31 +13,32 @@ exports.output = output;
13
13
function output ( file , content ) {
14
14
var fullPath = pathUtils . join ( OUTPUT_DIR , file ) ;
15
15
var dir = pathUtils . dirname ( fullPath ) ;
16
- return Q . when ( exports . makeDir ( dir ) , function ( error ) {
17
- qfs . write ( fullPath , exports . toString ( content ) ) ;
16
+ return Q . when ( exports . makeDir ( dir ) , function ( ) {
17
+ return qfs . write ( fullPath , exports . toString ( content ) ) ;
18
18
} ) ;
19
19
}
20
20
21
21
//recursively create directory
22
22
exports . makeDir = function ( p ) {
23
- p = pathUtils . normalize ( p ) ;
24
- var parts = p . split ( pathUtils . sep ) ;
25
- var path = "." ;
26
-
27
- // Recursively rebuild directory structure
28
- return qfs . exists ( p ) .
29
- then ( function createPart ( exists ) {
30
- if ( ! exists && parts . length ) {
31
- path = pathUtils . join ( path , parts . shift ( ) ) ;
32
- return qfs . exists ( path ) . then ( function ( exists ) {
33
- if ( ! exists ) {
34
- return qfs . makeDirectory ( path ) . then ( createPart , createPart ) ;
35
- } else {
36
- return createPart ( ) ;
37
- }
38
- } ) ;
39
- }
40
- } ) ;
23
+ p = pathUtils . normalize ( p ) ;
24
+ var parts = p . split ( pathUtils . sep ) ;
25
+
26
+ var makePartialDir = function makePartialDir ( path ) {
27
+ return qfs . makeDirectory ( path ) . then ( function ( ) {
28
+ if ( parts . length ) {
29
+ return makePartialDir ( pathUtils . join ( path , parts . shift ( ) ) ) ;
30
+ }
31
+ } , function ( error ) {
32
+ if ( error . code !== 'EEXIST' ) {
33
+ throw error ;
34
+ }
35
+ if ( parts . length ) {
36
+ return makePartialDir ( pathUtils . join ( path , parts . shift ( ) ) ) ;
37
+ }
38
+ } ) ;
39
+ } ;
40
+
41
+ return makePartialDir ( pathUtils . join ( '.' , parts . shift ( ) ) ) ;
41
42
} ;
42
43
43
44
exports . copyTemplate = function ( filename ) {
0 commit comments