Skip to content

Commit 84913af

Browse files
committed
wip
1 parent ef0fb47 commit 84913af

2 files changed

Lines changed: 6 additions & 29 deletions

File tree

src/Commands/Concerns/InteractsWithFilesystem.php

Lines changed: 4 additions & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -10,21 +10,13 @@ trait InteractsWithFilesystem
1010
protected function writeToFile(string $path, string $content, $overwrite = false, $append = false): bool
1111
{
1212
$filePath = $path;
13-
$flags = 0;
13+
$flags = 0; // Default: overwrite
1414

1515
if (file_exists($filePath)) {
16-
if ($overwrite) {
17-
$flags = 0; // Overwrite
18-
} elseif ($append) {
16+
if ($append) {
1917
$flags = FILE_APPEND; // Append
20-
} else {
21-
if (confirm('Output file already exists. Overwrite?', false)) {
22-
$flags = 0; // Overwrite
23-
} else {
24-
$this->error("File [$filePath] already exists. Use --overwrite or --append option.");
25-
26-
return self::FAILURE;
27-
}
18+
} elseif (!$overwrite && !confirm('Output file already exists. Overwrite?', false)) {
19+
return $this->error("File [$filePath] already exists. Use --overwrite or --append option.");
2820
}
2921
}
3022

@@ -33,17 +25,4 @@ protected function writeToFile(string $path, string $content, $overwrite = false
3325

3426
return self::SUCCESS;
3527
}
36-
37-
protected function findStageOverlayTemplate(): ?string
38-
{
39-
$stageTemplatesPath = Keep::getSetting('stage_templates');
40-
41-
if (! $stageTemplatesPath) {
42-
return null;
43-
}
44-
45-
$path = $stageTemplatesPath.'/'.$this->stage().'.env';
46-
47-
return file_exists($path) && is_readable($path) ? $path : null;
48-
}
4928
}

src/Commands/MergeCommand.php

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -57,9 +57,7 @@ public function process()
5757

5858
protected function prepareTemplateContents(): bool
5959
{
60-
$template = $this->argument('template')
61-
?? Keep::getSetting('template')
62-
?? text('Template file with placeholders', required: true);
60+
$template = $this->argument('template') ?? text('Template file with placeholders', required: true);
6361

6462
if (! file_exists($template) || ! is_readable($template)) {
6563
$this->error("Template file [$template] does not exist or is not readable.");
@@ -70,7 +68,7 @@ protected function prepareTemplateContents(): bool
7068
$this->info("Using base template file [$template].");
7169
$this->baseTemplate = new Template(file_get_contents($template));
7270

73-
$overlayTemplate = $this->option('overlay') ?? $this->findStageOverlayTemplate();
71+
$overlayTemplate = $this->option('overlay');
7472

7573
if ($overlayTemplate) {
7674
if (! file_exists($overlayTemplate) || ! is_readable($overlayTemplate)) {

0 commit comments

Comments
 (0)