diff --git a/src/actions/ScaffoldFiles.php b/src/actions/ScaffoldFiles.php index feb3055..d314f23 100644 --- a/src/actions/ScaffoldFiles.php +++ b/src/actions/ScaffoldFiles.php @@ -8,6 +8,7 @@ use Symfony\Component\Filesystem\Filesystem; use UniversityOfAdelaide\ShepherdDrupalScaffold\ScaffoldTrait; use UniversityOfAdelaide\ShepherdDrupalScaffold\tasks\CopyFile; +use UniversityOfAdelaide\ShepherdDrupalScaffold\tasks\DeleteFile; /** * Updates the Shepherd scaffold files. @@ -25,6 +26,10 @@ public function onEvent(Event $event): void foreach (static::tasks($this->filesystem, $scaffoldPath, $projectPath) as $task) { $task->execute(); } + + $event->getIO()->write('Deleting install.php'); + $delete = new DeleteFile($this->filesystem, 'web/core', 'install.php'); + $delete->execute(); } /** diff --git a/src/tasks/DeleteFile.php b/src/tasks/DeleteFile.php new file mode 100644 index 0000000..cd1c7db --- /dev/null +++ b/src/tasks/DeleteFile.php @@ -0,0 +1,44 @@ +filesystem = $filesystem; + $this->path = $path; + $this->filename = $filename; + } + + public function getFilename(): string + { + return $this->filename; + } + + /** + * @throws \Symfony\Component\Filesystem\Exception\FileNotFoundException + * When original file doesn't exist + * @throws \Symfony\Component\Filesystem\Exception\IOException + * When copy fails + */ + public function execute(): void + { + // Skip copying files that already exist at the destination. + if (!$this->filesystem->exists($this->path . '/' . $this->filename)) { + return; + } + + $this->filesystem->remove( + $this->path . '/' . $this->filename + ); + } +}