|
3 | 3 | namespace Native\Electron\Commands;
|
4 | 4 |
|
5 | 5 | use Illuminate\Console\Command;
|
| 6 | +use Native\Electron\Traits\SetsAppName; |
6 | 7 | use Symfony\Component\Filesystem\Filesystem;
|
7 | 8 |
|
8 | 9 | use function Laravel\Prompts\intro;
|
9 | 10 |
|
10 | 11 | class ResetCommand extends Command
|
11 | 12 | {
|
| 13 | + use SetsAppName; |
| 14 | + |
12 | 15 | protected $signature = 'native:reset {--with-app-data : Clear the app data as well}';
|
13 | 16 |
|
14 | 17 | protected $description = 'Clear all build and dist files';
|
@@ -43,18 +46,17 @@ public function handle(): int
|
43 | 46 |
|
44 | 47 | if ($this->option('with-app-data')) {
|
45 | 48 |
|
46 |
| - // Fetch last generated app name |
47 |
| - $packageJsonPath = __DIR__.'/../../resources/js/package.json'; |
48 |
| - $packageJson = json_decode(file_get_contents($packageJsonPath), true); |
49 |
| - $appName = $packageJson['name']; |
| 49 | + foreach ([true, false] as $developmentMode) { |
| 50 | + $appName = $this->setAppName($developmentMode); |
50 | 51 |
|
51 |
| - // Eh, just in case, I don't want to delete all user data by accident. |
52 |
| - if (! empty($appName)) { |
53 |
| - $appDataPath = $this->appDataDirectory($appName); |
54 |
| - $this->line('Clearing: '.$appDataPath); |
| 52 | + // Eh, just in case, I don't want to delete all user data by accident. |
| 53 | + if ( ! empty($appName)) { |
| 54 | + $appDataPath = $this->appDataDirectory($appName); |
| 55 | + $this->line('Clearing: '.$appDataPath); |
55 | 56 |
|
56 |
| - if ($filesystem->exists($appDataPath)) { |
57 |
| - $filesystem->remove($appDataPath); |
| 57 | + if ($filesystem->exists($appDataPath)) { |
| 58 | + $filesystem->remove($appDataPath); |
| 59 | + } |
58 | 60 | }
|
59 | 61 | }
|
60 | 62 | }
|
|
0 commit comments