From a154c77f89592b11db2f917abb862077bf3b8e73 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?C=C3=A9dric=20Belin?= Date: Sun, 14 Apr 2019 00:36:01 +0200 Subject: [PATCH] Updated the build system --- RoboFile.php | 29 +++++++++++++++++------------ 1 file changed, 17 insertions(+), 12 deletions(-) diff --git a/RoboFile.php b/RoboFile.php index 36f2195..e787189 100644 --- a/RoboFile.php +++ b/RoboFile.php @@ -16,14 +16,17 @@ class RoboFile extends Tasks { $path = (string) getenv('PATH'); $vendor = (string) realpath('vendor/bin'); if (strpos($path, $vendor) === false) putenv("PATH=$vendor".PATH_SEPARATOR.$path); + $this->stopOnFail(); } /** * Deletes all generated files and reset any saved state. */ - function clean(): void { - $this->_cleanDir('var'); - $this->_deleteDir(['build', 'doc/api', 'web']); + function clean(): Result { + return $this->collectionBuilder() + ->addTask($this->taskCleanDir('var')) + ->addTask($this->taskDeleteDir(['build', 'doc/api', 'web'])) + ->run(); } /** @@ -39,12 +42,14 @@ class RoboFile extends Tasks { * @return Result The task result. */ function doc(): Result { - $this->taskFilesystemStack() - ->copy('CHANGELOG.md', 'doc/about/changelog.md') - ->copy('LICENSE.md', 'doc/about/license.md') + return $this->collectionBuilder() + ->addTask($this->taskFilesystemStack() + ->copy('CHANGELOG.md', 'doc/about/changelog.md') + ->copy('LICENSE.md', 'doc/about/license.md')) + ->addTask($this->taskExec('mkdocs build --config-file=doc/mkdocs.yml')) + ->addTask($this->taskFilesystemStack() + ->remove(['doc/about/changelog.md', 'doc/about/license.md', 'web/mkdocs.yml', 'web/phpdoc.xml'])) ->run(); - - return $this->_exec('mkdocs build --config-file=doc/mkdocs.yml'); } /** @@ -72,7 +77,7 @@ class RoboFile extends Tasks { */ function upgrade(): Result { $composer = escapeshellarg(PHP_OS_FAMILY == 'Windows' ? 'C:\Program Files\PHP\share\composer.phar' : '/usr/local/bin/composer'); - return $this->taskExecStack()->stopOnFail() + return $this->taskExecStack() ->exec('git reset --hard') ->exec('git fetch --all --prune') ->exec('git pull --rebase') @@ -92,9 +97,9 @@ class RoboFile extends Tasks { /** * Watches for file changes. */ - function watch(): void { - $this->taskWatch() - ->monitor(['src', 'test'], function() { $this->test(); }) + function watch(): Result { + return $this->taskWatch() + ->monitor('test', function() { $this->test(); }) ->run(); } }