@@ -39,11 +39,11 @@ async function installDependencies(dirName) {
3939
4040async function initGit ( dirName ) {
4141 console . log ( `Setting up Git ...` )
42- await fs . remove ( ` ${ dirName } / .git` , { recursive : true } , async ( ) => {
43- await run (
44- `cd ${ dirName } && git init && git add . && git commit -m "New Stackbit project"`
45- )
46- } )
42+ // remove .git folder
43+ await fs . removeSync ( ` ${ dirName } / .git` )
44+ await run (
45+ `cd ${ dirName } && git init && git add . && git commit -m "New Stackbit project"`
46+ )
4747}
4848/**
4949 * Given a version string, compare it to a control version. Returns:
@@ -160,29 +160,19 @@ async function cloneExample() {
160160 // Checkout just the example dir.
161161 await run ( `cd ${ tmpDir } && git sparse-checkout set ${ args . example } ` )
162162
163- // Copy out into a new directory within current working directory.
164- await fs . copy ( `${ tmpDir } /${ args . example } ` , dirName , async ( err ) => {
165- if ( err ) {
166- console . log ( err )
167- }
168- } )
163+ // move out into a new directory.
164+ await fs . moveSync ( `${ tmpDir } /${ args . example } ` , dirName )
169165
170166 // Delete the clone.
171- await fs . remove ( tmpDir , { recursive : true } , ( err ) => {
172- if ( err ) {
173- console . log ( err )
174- }
175- } )
176-
177- if ( fs . existsSync ( path . join ( process . cwd ( ) , dirName ) ) )
178- await installDependencies ( path . join ( process . cwd ( ) , dirName ) )
167+ await fs . removeSync ( tmpDir )
168+
169+ await installDependencies ( dirName )
179170 // Project Setup
180- // await
181- // await initGit(prestineFolder)
171+ await initGit ( dirName )
182172 } catch ( err ) {
183-
184173 if ( fs . existsSync ( dirName ) ) await fs . remove ( dirName )
185174 if ( fs . existsSync ( tmpDir ) )
175+ // remove temp directory
186176 await fs . remove ( tmpDir , ( err ) => {
187177 if ( err ) {
188178 console . log ( err )
0 commit comments