Skip to content

Commit 5e68754

Browse files
committed
ignore development files on production env
Signed-off-by: MarioRadu <[email protected]>
1 parent fbfae3c commit 5e68754

File tree

2 files changed

+13
-14
lines changed

2 files changed

+13
-14
lines changed

bin/composer-post-install-script.php

+12-11
Original file line numberDiff line numberDiff line change
@@ -11,18 +11,20 @@
1111

1212
function copyFile(array $file): void
1313
{
14+
if (! in_array(getEnvironment(), $file['environment'])) {
15+
echo "Skipping the copy of {$file['source']} due to environment settings." . PHP_EOL;
16+
return;
17+
}
18+
1419
if (is_readable($file['destination'])) {
15-
echo "File {$file['destination']} already exists." . PHP_EOL;
20+
echo "File {$file['destination']} already exists. Skipping..." . PHP_EOL;
21+
return;
22+
}
23+
24+
if (! copy($file['source'], $file['destination'])) {
25+
echo "Cannot copy {$file['source']} file to {$file['destination']}" . PHP_EOL;
1626
} else {
17-
if (! in_array(getEnvironment(), $file['environment'])) {
18-
echo "Skipping the copy of {$file['source']} due to environment settings." . PHP_EOL;
19-
} else {
20-
if (! copy($file['source'], $file['destination'])) {
21-
echo "Cannot copy {$file['source']} file to {$file['destination']}" . PHP_EOL;
22-
} else {
23-
echo "File {$file['source']} copied successfully to {$file['destination']}." . PHP_EOL;
24-
}
25-
}
27+
echo "File {$file['source']} copied successfully to {$file['destination']}." . PHP_EOL;
2628
}
2729
}
2830

@@ -52,6 +54,5 @@ function getEnvironment(): string
5254
];
5355

5456
echo "Using environment setting: " . getEnvironment() . PHP_EOL;
55-
var_dump("getenv('COMPOSER_DEV_MODE')", getenv('COMPOSER_DEV_MODE'));
5657

5758
array_walk($files, 'copyFile');

composer.json

+1-3
Original file line numberDiff line numberDiff line change
@@ -107,9 +107,7 @@
107107
"@development-enable"
108108
],
109109
"post-update-cmd": [
110-
"laminas-development-mode status",
111-
"php bin/composer-post-install-script.php",
112-
"laminas-development-mode status"
110+
"php bin/composer-post-install-script.php"
113111
],
114112
"development-disable": "laminas-development-mode disable",
115113
"development-enable": "laminas-development-mode enable",

0 commit comments

Comments
 (0)