Skip to content

Commit 273d30a

Browse files
committed
fix: clean error for existing app dir + fix vite paths issue
1 parent 80cf1c9 commit 273d30a

4 files changed

Lines changed: 12 additions & 12 deletions

File tree

src/CreateCommand.php

Lines changed: 9 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,6 @@
55
namespace Leaf\Console;
66

77
use Leaf\Console\Utils\Package;
8-
use RuntimeException;
98
use Leaf\FS;
109
use Leaf\Sprout\Command;
1110

@@ -106,8 +105,12 @@ protected function handle(): int
106105
$commands = [];
107106
$directory = path($this->projectName !== '.' ? getcwd() . '/' . $this->projectName : getcwd())->normalize();
108107

109-
if (!$this->option('force')) {
110-
$this->verifyApplicationDoesntExist($directory);
108+
if (!$this->option('force') && $this->applicationExists($directory)) {
109+
$this->writeln('');
110+
$this->error('"' . basename($directory) . '" already exists in ./' . basename(dirname($directory)));
111+
$this->writeln('Choose a different name, or re-run with <info>--force</info> to build in the existing folder.');
112+
113+
return 1;
111114
}
112115

113116
$this->writeln(
@@ -312,15 +315,10 @@ protected function handle(): int
312315
}
313316

314317
/**
315-
* Verify that the application does not already exist.
316-
*
317-
* @param string $directory
318-
* @return void
318+
* Check whether something already exists at the target directory.
319319
*/
320-
protected function verifyApplicationDoesntExist(string $directory)
320+
protected function applicationExists(string $directory): bool
321321
{
322-
if ((is_dir($directory) || is_file($directory)) && $directory != getcwd()) {
323-
throw new RuntimeException('Application already exists!');
324-
}
322+
return (is_dir($directory) || is_file($directory)) && $directory != getcwd();
325323
}
326324
}

src/themes/vite/views/css/app.css

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
/* Your app's CSS entry. Loaded through Vite via the @vite directive. */

src/themes/vite/views/js/app.js

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
// Your app's JavaScript entry. Anything imported here is bundled by Vite.

src/themes/vite/vite.config.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ import leaf from '@leafphp/vite-plugin';
44
export default defineConfig({
55
plugins: [
66
leaf({
7-
input: ['js/app.js', 'css/app.css'],
7+
input: ['views/js/app.js', 'views/css/app.css'],
88
refresh: true,
99
}),
1010
],

0 commit comments

Comments
 (0)