Skip to content

Commit

Permalink
Smarter backup
Browse files Browse the repository at this point in the history
  • Loading branch information
caendesilva committed Jul 12, 2024
1 parent 40a40f0 commit 7c08e2c
Showing 1 changed file with 9 additions and 0 deletions.
9 changes: 9 additions & 0 deletions monorepo/DevTools/src/RefactorConfigCommand.php
Original file line number Diff line number Diff line change
Expand Up @@ -61,8 +61,13 @@ public function handle(): int

protected function migrateToYaml(): void
{
$usesGit = file_exists(Hyde::path('.git'));

if (file_exists(Hyde::path('hyde.yml')) && ! file_exists(Hyde::path('hyde.yml.bak'))) {
copy(Hyde::path('hyde.yml'), Hyde::path('hyde.yml.bak'));
if (! $usesGit) {
$this->warn("You're not using Git for version control, so a backup of your configuration has been created at hyde.yml.bak.");
}
}

try {
Expand All @@ -81,6 +86,10 @@ protected function migrateToYaml(): void
unlink(Hyde::path('hyde.yml.bak'));

return;
} finally {
if ($usesGit && file_exists(Hyde::path('hyde.yml.bak'))) {
unlink(Hyde::path('hyde.yml.bak'));
}
}
}

Expand Down

0 comments on commit 7c08e2c

Please sign in to comment.