Permalink
Browse files

[Command] Avoid exception if no 'build.properties' file

  • Loading branch information...
1 parent 90b1f3f commit 65905c8c99d54e38d095f9a82a3c5bb1a7fe03f2 @willdurand willdurand committed Jun 9, 2012
Showing with 12 additions and 10 deletions.
  1. +12 −10 src/Propel/Generator/Command/AbstractCommand.php
@@ -40,19 +40,21 @@ protected function getBuildProperties($file)
{
$properties = array();
- if (false === $lines = @file($file)) {
- throw new RuntimeException(sprintf('Unable to parse contents of "%s".', $file));
- }
+ if (file_exists($file)) {
+ if (false === $lines = @file($file)) {
+ throw new RuntimeException(sprintf('Unable to parse contents of "%s".', $file));
+ }
- foreach ($lines as $line) {
- $line = trim($line);
+ foreach ($lines as $line) {
+ $line = trim($line);
- if (empty($line) || in_array($line[0], array('#', ';'))) {
- continue;
- }
+ if (empty($line) || in_array($line[0], array('#', ';'))) {
+ continue;
+ }
- $pos = strpos($line, '=');
- $properties[trim(substr($line, 0, $pos))] = trim(substr($line, $pos + 1));
+ $pos = strpos($line, '=');
+ $properties[trim(substr($line, 0, $pos))] = trim(substr($line, $pos + 1));
+ }
}
return $properties;

0 comments on commit 65905c8

Please sign in to comment.