public function tearDown() { if ($this->originalComposerHome) { putenv('COMPOSER_HOME=' . $this->originalComposerHome); } // Composer home directory is created one level up from where composer.json is. if (is_dir($this->testComposerHome)) { $this->fileDriver->deleteDirectory($this->testComposerHome); } }
public function testCreateDirectory() { $generatedPath = $this->getTestPath('generated/roo/bar/baz/foo'); $generatedPathBase = $this->getTestPath('generated'); // Delete the generated directory if it already exists if (is_dir($generatedPath)) { $this->assertTrue($this->driver->deleteDirectory($generatedPathBase)); } $this->assertTrue($this->driver->createDirectory($generatedPath, '755')); $this->assertTrue(is_dir($generatedPath)); }
public function testCreateDirectory() { $generatedPath = $this->getTestPath('generated/roo/bar/baz/foo'); $generatedPathBase = $this->getTestPath('generated'); // Delete the generated directory if it already exists if (is_dir($generatedPath)) { $this->assertTrue($this->driver->deleteDirectory($generatedPathBase)); } $this->assertTrue($this->driver->createDirectory($generatedPath, DriverInterface::WRITEABLE_DIRECTORY_MODE)); $this->assertTrue(is_dir($generatedPath)); }
/** * Deletes specified directories by code * * @param array $directoryCodeList * @return void */ public function cleanupFilesystem($directoryCodeList) { $excludePatterns = ['#.htaccess#', '#deployed_version.txt#']; foreach ($directoryCodeList as $code) { if ($code == DirectoryList::STATIC_VIEW) { $directoryPath = $this->directoryList->getPath(DirectoryList::STATIC_VIEW); if ($this->driverFile->isExists($directoryPath)) { $files = $this->driverFile->readDirectory($directoryPath); foreach ($files as $file) { foreach ($excludePatterns as $pattern) { if (preg_match($pattern, $file)) { continue 2; } } if ($this->driverFile->isFile($file)) { $this->driverFile->deleteFile($file); } else { $this->driverFile->deleteDirectory($file); } } } } else { $this->filesystem->getDirectoryWrite($code)->delete(); } } }
/** * Determine whether a CLI command is for compilation, and if so, clear the directory * * @throws \Magento\Framework\Exception\FileSystemException * @return void */ public function handleCompilerEnvironment() { $compilationCommands = [DiCompileCommand::NAME, DiCompileMultiTenantCommand::NAME]; $cmdName = $this->input->getFirstArgument(); $isHelpOption = $this->input->hasParameterOption('--help') || $this->input->hasParameterOption('-h'); if (!in_array($cmdName, $compilationCommands) || $isHelpOption) { return; } $generationDir = $cmdName === DiCompileMultiTenantCommand::NAME ? $this->input->getParameterOption(DiCompileMultiTenantCommand::INPUT_KEY_GENERATION) : null; if (!$generationDir) { $mageInitParams = $this->serviceManager->get(InitParamListener::BOOTSTRAP_PARAM); $mageDirs = isset($mageInitParams[Bootstrap::INIT_PARAM_FILESYSTEM_DIR_PATHS]) ? $mageInitParams[Bootstrap::INIT_PARAM_FILESYSTEM_DIR_PATHS] : []; $generationDir = (new DirectoryList(BP, $mageDirs))->getPath(DirectoryList::GENERATION); } if ($this->filesystemDriver->isExists($generationDir)) { $this->filesystemDriver->deleteDirectory($generationDir); } }
/** * Determine whether a CLI command is for compilation, and if so, clear the directory * * @throws \Magento\Framework\Exception\FileSystemException * @return void */ public function handleCompilerEnvironment() { $compilationCommands = [DiCompileCommand::NAME]; $cmdName = $this->input->getFirstArgument(); $isHelpOption = $this->input->hasParameterOption('--help') || $this->input->hasParameterOption('-h'); if (!in_array($cmdName, $compilationCommands) || $isHelpOption) { return; } $compileDirList = []; $mageInitParams = $this->serviceManager->get(InitParamListener::BOOTSTRAP_PARAM); $mageDirs = isset($mageInitParams[Bootstrap::INIT_PARAM_FILESYSTEM_DIR_PATHS]) ? $mageInitParams[Bootstrap::INIT_PARAM_FILESYSTEM_DIR_PATHS] : []; $directoryList = new DirectoryList(BP, $mageDirs); $compileDirList[] = $directoryList->getPath(DirectoryList::GENERATION); $compileDirList[] = $directoryList->getPath(DirectoryList::DI); foreach ($compileDirList as $compileDir) { if ($this->filesystemDriver->isExists($compileDir)) { $this->filesystemDriver->deleteDirectory($compileDir); } } }