Skip to content

Commit

Permalink
ignore development files on production env
Browse files Browse the repository at this point in the history
Signed-off-by: MarioRadu <magda_marior@yahoo.com>
  • Loading branch information
MarioRadu committed Dec 12, 2024
1 parent fbfae3c commit 5e68754
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 14 deletions.
23 changes: 12 additions & 11 deletions bin/composer-post-install-script.php
Original file line number Diff line number Diff line change
Expand Up @@ -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;
}
}

Expand Down Expand Up @@ -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');
4 changes: 1 addition & 3 deletions composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -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",
Expand Down

0 comments on commit 5e68754

Please sign in to comment.