Fix autoload generation for dev dependencies when --no-scripts is used, fixes #9934

main
Jordi Boggiano 3 years ago
parent c686bbd7e2
commit d5ce7a7385
No known key found for this signature in database
GPG Key ID: 7BBD42C429EC80BC

@ -145,19 +145,23 @@ class AutoloadGenerator
// Force scanPsrPackages when classmap is authoritative
$scanPsrPackages = true;
}
if ($this->runScripts) {
// auto-set devMode based on whether dev dependencies are installed or not
if (null === $this->devMode) {
// we assume no-dev mode if no vendor dir is present or it is too old to contain dev information
$this->devMode = false;
$installedJson = new JsonFile($config->get('vendor-dir').'/composer/installed.json');
$isDevInstall = null;
if ($installedJson->exists()) {
$installedJson = $installedJson->read();
$isDevInstall = isset($installedJson['dev']) ? $installedJson['dev'] : null;
}
// auto-set devMode based on whether dev dependencies are installed or not
if (null !== $isDevInstall && null === $this->devMode) {
$this->devMode = $isDevInstall;
if (isset($installedJson['dev'])) {
$this->devMode = $installedJson['dev'];
}
}
}
// set COMPOSER_DEV_MODE in case not set yet so it is available in the dump-autoload autoload
if ($this->runScripts) {
// set COMPOSER_DEV_MODE in case not set yet so it is available in the dump-autoload event listeners
if (!isset($_SERVER['COMPOSER_DEV_MODE'])) {
Platform::putEnv('COMPOSER_DEV_MODE', $this->devMode ? '1' : '0');
}

Loading…
Cancel
Save