/** * Process shared file mounts in the application. * * For each "mount", this creates a corresponding directory in the project's * shared files directory, and symlinks it into the appropriate path in the * build. */ protected function processSharedFileMounts() { $sharedDir = $this->getSharedDir(); if ($sharedDir === false) { return; } // If the build directory is a symlink, then skip, so that we don't risk // modifying the user's repository. if (is_link($this->buildDir)) { return; } $sharedFileMounts = $this->app->getSharedFileMounts(); if (empty($sharedFileMounts)) { return; } $sharedDirRelative = $this->config->get('local.shared_dir'); $this->output->writeln('Creating symbolic links to mimic shared file mounts'); foreach ($sharedFileMounts as $appPath => $sharedPath) { $target = $sharedDir . '/' . $sharedPath; $targetRelative = $sharedDirRelative . '/' . $sharedPath; $link = $this->buildDir . '/' . $appPath; if (file_exists($link) && !is_link($link)) { $this->output->writeln(' Overwriting existing file <comment>' . $appPath . '</comment>'); } if (!file_exists($target)) { $this->fsHelper->mkdir($target, 0775); } $this->output->writeln(' Symlinking <info>' . $appPath . '</info> to <info>' . $targetRelative . '</info>'); $this->fsHelper->symlink($target, $link); } }
public function testGetSharedFileMounts() { $appRoot = 'tests/data/apps/drupal/project'; $app = new LocalApplication($appRoot); $this->assertEquals(['public/sites/default/files' => 'files', 'tmp' => 'tmp', 'private' => 'private', 'drush-backups' => 'drush-backups'], $app->getSharedFileMounts()); }