From 69cc83a04abd526af8b275e66556e5b5fe71f0b6 Mon Sep 17 00:00:00 2001 From: Cam Spiers Date: Sat, 10 Aug 2013 13:34:19 +1200 Subject: [PATCH] Check if build artifacts exist before deleting them --- PHPCI/Plugin/Pdepend.php | 21 +++++++++++++++------ 1 file changed, 15 insertions(+), 6 deletions(-) diff --git a/PHPCI/Plugin/Pdepend.php b/PHPCI/Plugin/Pdepend.php index 95a7a8c0..285c86bc 100644 --- a/PHPCI/Plugin/Pdepend.php +++ b/PHPCI/Plugin/Pdepend.php @@ -68,11 +68,7 @@ class Pdepend implements \PHPCI\Plugin $cmd = PHPCI_BIN_DIR . 'pdepend --summary-xml=%s --jdepend-chart=%s --overview-pyramid=%s "%s"'; - //Remove the created files first - unlink($this->location . DIRECTORY_SEPARATOR . $this->summary); - unlink($this->location . DIRECTORY_SEPARATOR . $this->chart); - unlink($this->location . DIRECTORY_SEPARATOR . $this->pyramid); - + $this->removeBuildArtifacts(); $success = $this->phpci->executeCommand( $cmd, $this->location . DIRECTORY_SEPARATOR . $this->summary, @@ -101,4 +97,17 @@ class Pdepend implements \PHPCI\Plugin return $success; } -} \ No newline at end of file + + /** + * Remove files created from previous builds + */ + protected function removeBuildArtifacts() + { + //Remove the created files first + foreach (array($this->summary, $this->chart, $this->pyramid) as $file) { + if (file_exists($this->location . DIRECTORY_SEPARATOR . $file)) { + unlink($this->location . DIRECTORY_SEPARATOR . $file); + } + } + } +}