@@ -89,12 +89,28 @@ protected function interact(InputInterface $input, OutputInterface $output)
8989 label: 'What is the name of your project? ' ,
9090 placeholder: 'E.g. example-app ' ,
9191 required: 'The project name is required. ' ,
92- validate: fn ($ value ) => preg_match ('/[^\pL\pN\-_.]/ ' , $ value ) !== 0
93- ? 'The name may only contain letters, numbers, dashes, underscores, and periods. '
94- : null ,
92+ validate: function ($ value ) use ($ input ) {
93+ if (preg_match ('/[^\pL\pN\-_.]/ ' , $ value ) !== 0 ) {
94+ return 'The name may only contain letters, numbers, dashes, underscores, and periods. ' ;
95+ }
96+
97+ if ($ input ->getOption ('force ' ) !== true ) {
98+ try {
99+ $ this ->verifyApplicationDoesntExist ($ this ->getInstallationDirectory ($ value ));
100+ } catch (RuntimeException $ e ) {
101+ return 'Application already exists. ' ;
102+ }
103+ }
104+ },
95105 ));
96106 }
97107
108+ if ($ input ->getOption ('force ' ) !== true ) {
109+ $ this ->verifyApplicationDoesntExist (
110+ $ this ->getInstallationDirectory ($ input ->getArgument ('name ' ))
111+ );
112+ }
113+
98114 if (! $ input ->getOption ('breeze ' ) && ! $ input ->getOption ('jet ' )) {
99115 match (select (
100116 label: 'Would you like to install a starter kit? ' ,
@@ -144,7 +160,7 @@ protected function execute(InputInterface $input, OutputInterface $output): int
144160
145161 $ name = $ input ->getArgument ('name ' );
146162
147- $ directory = $ name !== ' . ' ? getcwd (). ' / ' . $ name : ' . ' ;
163+ $ directory = $ this -> getInstallationDirectory ( $ name) ;
148164
149165 $ this ->composer = new Composer (new Filesystem (), $ directory );
150166
@@ -788,6 +804,17 @@ protected function isParked(string $directory)
788804 return $ output !== false ? in_array (dirname ($ directory ), json_decode ($ output )) : false ;
789805 }
790806
807+ /**
808+ * Get the installation directory.
809+ *
810+ * @param string $name
811+ * @return string
812+ */
813+ protected function getInstallationDirectory (string $ name )
814+ {
815+ return $ name !== '. ' ? getcwd ().'/ ' .$ name : '. ' ;
816+ }
817+
791818 /**
792819 * Get the version that should be downloaded.
793820 *
0 commit comments