1
0
Fork 0

Pass devMode from RunScriptCommand to Script\Event

pull/5669/head
Den Girnyk 2016-07-21 15:32:31 +03:00 committed by Jordi Boggiano
parent ff7daf0bd4
commit 71e0fba216
2 changed files with 10 additions and 3 deletions

View File

@ -12,7 +12,7 @@
namespace Composer\Command; namespace Composer\Command;
use Composer\Script\CommandEvent; use Composer\Script\Event as ScriptEvent;
use Composer\Script\ScriptEvents; use Composer\Script\ScriptEvents;
use Composer\Util\ProcessExecutor; use Composer\Util\ProcessExecutor;
use Symfony\Component\Console\Input\InputInterface; use Symfony\Component\Console\Input\InputInterface;
@ -81,7 +81,9 @@ EOT
} }
$composer = $this->getComposer(); $composer = $this->getComposer();
$hasListeners = $composer->getEventDispatcher()->hasEventListeners(new CommandEvent($script, $composer, $this->getIO())); $devMode = $input->getOption('dev') || !$input->getOption('no-dev');
$event = new ScriptEvent($script, $composer, $this->getIO(), $devMode);
$hasListeners = $composer->getEventDispatcher()->hasEventListeners($event);
if (!$hasListeners) { if (!$hasListeners) {
throw new \InvalidArgumentException(sprintf('Script "%s" is not defined in this package', $script)); throw new \InvalidArgumentException(sprintf('Script "%s" is not defined in this package', $script));
} }
@ -96,7 +98,7 @@ EOT
ProcessExecutor::setTimeout((int) $timeout); ProcessExecutor::setTimeout((int) $timeout);
} }
return $composer->getEventDispatcher()->dispatchScript($script, $input->getOption('dev') || !$input->getOption('no-dev'), $args); return $composer->getEventDispatcher()->dispatchScript($script, $devMode, $args);
} }
protected function listScripts() protected function listScripts()

View File

@ -24,6 +24,7 @@ use Composer\Script;
use Composer\Script\CommandEvent; use Composer\Script\CommandEvent;
use Composer\Script\PackageEvent; use Composer\Script\PackageEvent;
use Composer\Util\ProcessExecutor; use Composer\Util\ProcessExecutor;
use Composer\Script\Event as ScriptEvent;
use Symfony\Component\Process\PhpExecutableFinder; use Symfony\Component\Process\PhpExecutableFinder;
/** /**
@ -415,6 +416,10 @@ class EventDispatcher
} }
$generator = $this->composer->getAutoloadGenerator(); $generator = $this->composer->getAutoloadGenerator();
if ($event instanceof ScriptEvent) {
$generator->setDevMode($event->isDevMode());
}
$packages = $this->composer->getRepositoryManager()->getLocalRepository()->getCanonicalPackages(); $packages = $this->composer->getRepositoryManager()->getLocalRepository()->getCanonicalPackages();
$packageMap = $generator->buildPackageMap($this->composer->getInstallationManager(), $package, $packages); $packageMap = $generator->buildPackageMap($this->composer->getInstallationManager(), $package, $packages);
$map = $generator->parseAutoloads($packageMap, $package); $map = $generator->parseAutoloads($packageMap, $package);