Skip to content

Commit 20bb143

Browse files
committed
requested changes
Signed-off-by: MarioRadu <magda_marior@yahoo.com>
1 parent 2c0b76a commit 20bb143

File tree

1 file changed

+11
-10
lines changed

1 file changed

+11
-10
lines changed

bin/composer-post-install-script.php

Lines changed: 11 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -2,14 +2,17 @@
22

33
declare(strict_types=1);
44

5+
const ENVIRONMENT_DEVELOPMENT = 'development';
6+
const ENVIRONMENT_PRODUCTION = 'production';
7+
58
// phpcs:disable PSR1.Files.SideEffects.FoundWithSymbols
69

710
function copyFile(array $file): void
811
{
912
if (is_readable($file['destination'])) {
1013
echo "File {$file['destination']} already exists." . PHP_EOL;
1114
} else {
12-
if (! isDevModeEnabled() && $file['environment'] === 'local') {
15+
if (! in_array(getEnvironment(), $file['environment'])) {
1316
echo "Skipping the copy of {$file['source']} due to environment settings." . PHP_EOL;
1417
} else {
1518
if (! copy($file['source'], $file['destination'])) {
@@ -21,30 +24,28 @@ function copyFile(array $file): void
2124
}
2225
}
2326

24-
function isDevModeEnabled(): bool
27+
function getEnvironment(): string
2528
{
26-
return file_exists('config/autoload/development.local.php');
29+
return file_exists('config/autoload/development.local.php') ? ENVIRONMENT_DEVELOPMENT : ENVIRONMENT_PRODUCTION;
2730
}
2831

29-
// when adding files to the below array the `source` and `destination` must be relative to the project root folder
30-
// the `environment` key will indicate when the file should be copied,
31-
// if the value is `production` the file will be copied on both production and local environments,
32-
// if the value is `local` the file will be copied only on local environments
32+
// when adding files to the below array the `source` and `destination` paths must be relative to the project root folder
33+
// the `environment` key will indicate on what environments the file will be copied,
3334
$files = [
3435
[
3536
'source' => 'config/autoload/local.php.dist',
3637
'destination' => 'config/autoload/local.php',
37-
'environment' => 'production',
38+
'environment' => [ENVIRONMENT_DEVELOPMENT, ENVIRONMENT_PRODUCTION],
3839
],
3940
[
4041
'source' => 'config/autoload/local.test.php.dist',
4142
'destination' => 'config/autoload/local.test.php',
42-
'environment' => 'local',
43+
'environment' => [ENVIRONMENT_DEVELOPMENT],
4344
],
4445
[
4546
'source' => 'vendor/dotkernel/dot-mail/config/mail.global.php.dist',
4647
'destination' => 'config/autoload/mail.global.php',
47-
'environment' => 'production',
48+
'environment' => [ENVIRONMENT_DEVELOPMENT, ENVIRONMENT_PRODUCTION],
4849
],
4950
];
5051

0 commit comments

Comments
 (0)