@@ -66,7 +66,7 @@ export const createProjectDirectory = async (
6666 ) ;
6767 } catch ( error ) {
6868 spinner . fail ( ) ;
69- console . log ( "" )
69+ console . log ( "" ) ;
7070 throw new Error ( error ) ;
7171 }
7272} ;
@@ -88,12 +88,22 @@ export const installDependencies = async (
8888 const installCommand = "npm" ;
8989 let installArgs = [ "install" , "--save" ] ;
9090 installArgs = installArgs . concat ( dependencies ) ;
91- // * Create a process that installs the dependencies
92- await executeCommand ( installCommand , installArgs , { cwd : root } ) ;
93- spinner . succeed ( "Dependencies installed successfully" ) ;
91+ // * Verify that the directory exists 1st
92+ const pathExists = await fs . pathExists ( root ) ;
93+ if ( pathExists ) {
94+ // * Create a process that installs the dependencies
95+ await executeCommand ( installCommand , installArgs , {
96+ cwd : root ,
97+ shell : process . platform === "win32" ,
98+ } ) ;
99+ spinner . succeed ( "Dependencies installed successfully" ) ;
100+ } else {
101+ spinner . fail ( `Path: ${ root } does not exist.` ) ;
102+ throw new Error ( `Path: ${ root } does not exist.` ) ;
103+ }
94104 } catch ( error ) {
95105 spinner . fail ( ) ;
96- console . log ( "" )
106+ console . log ( "" ) ;
97107 throw new Error ( error ) ;
98108 }
99109} ;
@@ -124,12 +134,22 @@ export const installDevDependencies = async (
124134 installArgs = installArgs . concat ( devDependencies ) ;
125135 }
126136
127- // * Creates a process that installs the dev dependencies
128- await executeCommand ( installCommand , installArgs , { cwd : root } ) ;
129- spinner . succeed ( "DevDependencies installed successfully" ) ;
137+ // * Verify that the directory exists 1st
138+ const pathExists = await fs . pathExists ( root ) ;
139+ if ( pathExists ) {
140+ // * Create a process that installs the dependencies
141+ await executeCommand ( installCommand , installArgs , {
142+ cwd : root ,
143+ shell : process . platform === "win32" ,
144+ } ) ;
145+ spinner . succeed ( "DevDependencies installed successfully" ) ;
146+ } else {
147+ spinner . fail ( `Path: ${ root } does not exist.` ) ;
148+ throw new Error ( `Path: ${ root } does not exist.` ) ;
149+ }
130150 } catch ( error ) {
131151 spinner . fail ( ) ;
132- console . log ( "" )
152+ console . log ( "" ) ;
133153 throw new Error ( error ) ;
134154 }
135155} ;
@@ -190,7 +210,7 @@ export const copyTemplateFiles = async (
190210 spinner . succeed ( "Template files copied successfully" ) ;
191211 } catch ( error ) {
192212 spinner . fail ( ) ;
193- console . log ( "" )
213+ console . log ( "" ) ;
194214 throw new Error ( error ) ;
195215 }
196216} ;
@@ -242,7 +262,7 @@ export const replaceTemplateValues = async (
242262 spinner . succeed ( "Values in template files replaced successfully" ) ;
243263 } catch ( error ) {
244264 spinner . fail ( ) ;
245- console . log ( "" )
265+ console . log ( "" ) ;
246266 throw new Error ( error ) ;
247267 }
248268} ;
@@ -283,7 +303,7 @@ export const createTSConfig = async (
283303 spinner . succeed ( "tsconfig.json created successfully" ) ;
284304 } catch ( error ) {
285305 spinner . fail ( ) ;
286- console . log ( "" )
306+ console . log ( "" ) ;
287307 throw new Error ( error ) ;
288308 }
289309} ;
0 commit comments