diff --git a/bin/composer-post-install-script.php b/bin/composer-post-install-script.php index 93db277..c453f96 100644 --- a/bin/composer-post-install-script.php +++ b/bin/composer-post-install-script.php @@ -11,18 +11,20 @@ function copyFile(array $file): void { + if (! in_array(getEnvironment(), $file['environment'])) { + echo "Skipping the copy of {$file['source']} due to environment settings." . PHP_EOL; + return; + } + if (is_readable($file['destination'])) { - echo "File {$file['destination']} already exists." . PHP_EOL; + echo "File {$file['destination']} already exists. Skipping..." . PHP_EOL; + return; + } + + if (! copy($file['source'], $file['destination'])) { + echo "Cannot copy {$file['source']} file to {$file['destination']}" . PHP_EOL; } else { - if (! in_array(getEnvironment(), $file['environment'])) { - echo "Skipping the copy of {$file['source']} due to environment settings." . PHP_EOL; - } else { - if (! copy($file['source'], $file['destination'])) { - echo "Cannot copy {$file['source']} file to {$file['destination']}" . PHP_EOL; - } else { - echo "File {$file['source']} copied successfully to {$file['destination']}." . PHP_EOL; - } - } + echo "File {$file['source']} copied successfully to {$file['destination']}." . PHP_EOL; } } @@ -52,6 +54,5 @@ function getEnvironment(): string ]; echo "Using environment setting: " . getEnvironment() . PHP_EOL; -var_dump("getenv('COMPOSER_DEV_MODE')", getenv('COMPOSER_DEV_MODE')); array_walk($files, 'copyFile'); diff --git a/composer.json b/composer.json index ee94f26..3f9c051 100644 --- a/composer.json +++ b/composer.json @@ -107,9 +107,7 @@ "@development-enable" ], "post-update-cmd": [ - "laminas-development-mode status", - "php bin/composer-post-install-script.php", - "laminas-development-mode status" + "php bin/composer-post-install-script.php" ], "development-disable": "laminas-development-mode disable", "development-enable": "laminas-development-mode enable",