@@ -85,20 +85,7 @@ export async function downloadTemplate(
8585 "-" ,
8686 ) ;
8787
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
10289 const temporaryDirectory = resolve (
10390 cacheDirectory ( ) ,
10491 providerName ,
@@ -137,6 +124,21 @@ export async function downloadTemplate(
137124 ) ;
138125 }
139126
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+
140142 const s = Date . now ( ) ;
141143 const subdir = template . subdir ?. replace ( / ^ \/ / , "" ) || "" ;
142144 await extract ( {
0 commit comments