From 71cbd8f7e69bc5b5006ca658655619e6317a53f7 Mon Sep 17 00:00:00 2001 From: Jordi Boggiano Date: Thu, 5 May 2016 23:20:54 +0100 Subject: [PATCH] Switch dir before loading plugins to make sure the correct composer.json is initialized, fixes #5290 --- src/Composer/Console/Application.php | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-) diff --git a/src/Composer/Console/Application.php b/src/Composer/Console/Application.php index c6b9bd377..9c153542e 100644 --- a/src/Composer/Console/Application.php +++ b/src/Composer/Console/Application.php @@ -109,6 +109,13 @@ class Application extends BaseApplication $io = $this->io = new ConsoleIO($input, $output, $this->getHelperSet()); ErrorHandler::register($io); + // switch working dir + if ($newWorkDir = $this->getNewWorkingDir($input)) { + $oldWorkingDir = getcwd(); + chdir($newWorkDir); + $io->writeError('Changed CWD to ' . getcwd(), true, IOInterface::DEBUG); + } + // determine command name to be executed without including plugin commands $commandName = ''; if ($name = $this->getCommandName($input)) { @@ -188,13 +195,6 @@ class Application extends BaseApplication } }); - // switch working dir - if ($newWorkDir = $this->getNewWorkingDir($input)) { - $oldWorkingDir = getcwd(); - chdir($newWorkDir); - $io->writeError('Changed CWD to ' . getcwd(), true, IOInterface::DEBUG); - } - // add non-standard scripts as own commands $file = Factory::getComposerFile(); if (is_file($file) && is_readable($file) && is_array($composer = json_decode(file_get_contents($file), true))) {