Skip to content

Commit 109848b

Browse files
committed
fix(stack): detect existing compose files via getComposeFilePath before creating default; fixes #91
1 parent 58fd20c commit 109848b

1 file changed

Lines changed: 8 additions & 4 deletions

File tree

source/compose.manager/php/util.php

Lines changed: 8 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1913,11 +1913,15 @@ public static function createNew(
19131913
*/
19141914
private static function writeDefaultComposeFile(string $dir): string
19151915
{
1916+
// Check for any existing compose file before creating a new one
1917+
$existing = self::getComposeFilePath($dir);
1918+
if ($existing !== null) {
1919+
return $existing;
1920+
}
1921+
19161922
$filePath = "$dir/" . COMPOSE_FILE_NAMES[0];
1917-
if (!file_exists($filePath)) {
1918-
if (file_put_contents($filePath, "services:\n") === false) {
1919-
throw new \RuntimeException("Failed to create default compose file: $filePath");
1920-
}
1923+
if (file_put_contents($filePath, "services:\n") === false) {
1924+
throw new \RuntimeException("Failed to create default compose file: $filePath");
19211925
}
19221926
return $filePath;
19231927
}

0 commit comments

Comments
 (0)