Skip to content

Commit

Permalink
Fix bug in --load-from
Browse files Browse the repository at this point in the history
  • Loading branch information
greg-1-anderson committed Sep 8, 2016
1 parent 06e77d3 commit df954d7
Showing 1 changed file with 21 additions and 8 deletions.
29 changes: 21 additions & 8 deletions src/Runner.php
Original file line number Diff line number Diff line change
Expand Up @@ -168,14 +168,20 @@ protected function instantiateCommandClass($commandClass)

// Register the RoboFile with the container and then immediately
// fetch it; this ensures that all of the inflectors will run.
$commandFileName = "{$commandClass}Commands";
$container->share($commandFileName, $commandClass);
$roboCommandFileInstance = $container->get($commandFileName);
if ($roboCommandFileInstance instanceof BuilderAwareInterface) {
$builder = $container->get('collectionBuilder', [$roboCommandFileInstance]);
$roboCommandFileInstance->setBuilder($builder);
// If the command class is already an instantiated object, then
// just use it exactly as it was provided to us.
if (is_string($commandClass)) {
$commandFileName = "{$commandClass}Commands";
$container->share($commandFileName, $commandClass);
$commandClass = $container->get($commandFileName);
}
return $roboCommandFileInstance;
// If the command class is a Builder Aware Interface, then
//
if ($commandClass instanceof BuilderAwareInterface) {
$builder = $container->get('collectionBuilder', [$commandClass]);
$commandClass->setBuilder($builder);
}
return $commandClass;
}

public function installRoboHandlers()
Expand Down Expand Up @@ -289,7 +295,14 @@ protected function prepareInput($argv)
$this->roboClass = $className;
}
}
chdir($this->dir);
// Convert directory to a real path, but only if the
// path exists. We do not want to lose the original
// directory if the user supplied a bad value.
$realDir = realpath($this->dir);
if ($realDir) {
chdir($realDir);
$this->dir = $realDir;
}
}
$input = new ArgvInput($argv);
if (!empty($passThroughArgs)) {
Expand Down

0 comments on commit df954d7

Please sign in to comment.