@@ -85,20 +85,7 @@ export async function downloadTemplate(
85
85
"-" ,
86
86
) ;
87
87
88
- const cwd = resolve ( options . cwd || "." ) ;
89
- const extractPath = resolve ( cwd , options . dir || template . defaultDir ) ;
90
- if ( options . forceClean ) {
91
- await rm ( extractPath , { recursive : true , force : true } ) ;
92
- }
93
- if (
94
- ! options . force &&
95
- existsSync ( extractPath ) &&
96
- readdirSync ( extractPath ) . length > 0
97
- ) {
98
- throw new Error ( `Destination ${ extractPath } already exists.` ) ;
99
- }
100
- await mkdir ( extractPath , { recursive : true } ) ;
101
-
88
+ // Download template source
102
89
const temporaryDirectory = resolve (
103
90
cacheDirectory ( ) ,
104
91
providerName ,
@@ -137,6 +124,21 @@ export async function downloadTemplate(
137
124
) ;
138
125
}
139
126
127
+ // Extract template
128
+ const cwd = resolve ( options . cwd || "." ) ;
129
+ const extractPath = resolve ( cwd , options . dir || template . defaultDir ) ;
130
+ if ( options . forceClean ) {
131
+ await rm ( extractPath , { recursive : true , force : true } ) ;
132
+ }
133
+ if (
134
+ ! options . force &&
135
+ existsSync ( extractPath ) &&
136
+ readdirSync ( extractPath ) . length > 0
137
+ ) {
138
+ throw new Error ( `Destination ${ extractPath } already exists.` ) ;
139
+ }
140
+ await mkdir ( extractPath , { recursive : true } ) ;
141
+
140
142
const s = Date . now ( ) ;
141
143
const subdir = template . subdir ?. replace ( / ^ \/ / , "" ) || "" ;
142
144
await extract ( {
0 commit comments