File tree Expand file tree Collapse file tree 1 file changed +21
-14
lines changed
Expand file tree Collapse file tree 1 file changed +21
-14
lines changed Original file line number Diff line number Diff line change @@ -95,20 +95,27 @@ async function cloneExample() {
9595 const tmpDir = `examples-sparse-${ timestamp } ` ;
9696 console . log ( `\nCreating new project in ${ dirName } ...` ) ;
9797
98- // Sparse clone the monorepo.
99- await run (
100- `git clone --depth 1 --filter=blob:none --sparse ${ config . examples . repoUrl } ${ tmpDir } `
101- ) ;
102- // Checkout just the example dir.
103- await run ( `cd ${ tmpDir } && git sparse-checkout set ${ args . example } ` ) ;
104- // Copy out into a new directory within current working directory.
105- await run ( `cp -R ${ tmpDir } /${ args . example } ${ dirName } ` ) ;
106- // Delete the clone.
107- await run ( `rm -rf ${ tmpDir } ` ) ;
108-
109- // Project Setup
110- await installDependencies ( ) ;
111- await initGit ( ) ;
98+ try {
99+ // Sparse clone the monorepo.
100+ await run (
101+ `git clone --depth 1 --filter=blob:none --sparse ${ config . examples . repoUrl } ${ tmpDir } `
102+ ) ;
103+ // Checkout just the example dir.
104+ await run ( `cd ${ tmpDir } && git sparse-checkout set ${ args . example } ` ) ;
105+ // Copy out into a new directory within current working directory.
106+ await run ( `cp -R ${ tmpDir } /${ args . example } ${ dirName } ` ) ;
107+ // Delete the clone.
108+ await run ( `rm -rf ${ tmpDir } ` ) ;
109+
110+ // Project Setup
111+ await installDependencies ( ) ;
112+ await initGit ( ) ;
113+ } catch ( err ) {
114+ console . error ( err ) ;
115+ if ( fs . existsSync ( dirName ) ) await run ( `rm -rf ${ dirName } ` ) ;
116+ if ( fs . existsSync ( tmpDir ) ) await run ( `rm -rf ${ tmpDir } ` ) ;
117+ process . exit ( 1 ) ;
118+ }
112119
113120 // Output next steps:
114121 console . log ( `
You can’t perform that action at this time.
0 commit comments