Skip to content

Commit

Permalink
handling of directories in --pakefile= #37
Browse files Browse the repository at this point in the history
  • Loading branch information
indeyets committed Oct 25, 2013
1 parent be36410 commit 81a58c5
Showing 1 changed file with 21 additions and 3 deletions.
24 changes: 21 additions & 3 deletions lib/pake/pakeApp.class.php
Original file line number Diff line number Diff line change
Expand Up @@ -299,12 +299,30 @@ public function handle_options($options = null)
// If a match is found, it is copied into @pakefile.
public function have_pakefile()
{
$is_windows = (strtolower(substr(PHP_OS, 0, 3)) == 'win');

$here = getcwd();
foreach ($this->PAKEFILES as $file) {
$filepath = $here . '/' . $file;
$path_includes_directory = basename($file) !== $file;

if ($path_includes_directory) {
if ($is_windows) {
$is_absolute_path = ($file[0] == '\\' or $file[0] == '/' or mb_ereg('^[A-Za-z]+:', $file) === 1);
} else {
$is_absolute_path = $file[0] == '/';
}
} else {
$is_absolute_path = false;
}

if ($is_absolute_path) {
$filepath = $file;
} else {
$filepath = $here . DIRECTORY_SEPARATOR . $file;
}

if (file_exists($filepath)) {
$this->pakefile = $filepath;
$this->pakefile = realpath($filepath);
return true;
}
}
Expand All @@ -326,7 +344,7 @@ public function load_pakefile()
$here = getcwd();
}

require($this->pakefile);
require $this->pakefile;
chdir($start);
}

Expand Down

0 comments on commit 81a58c5

Please sign in to comment.