Browse Source

Replace file/folder manipulation with Flysystem library

shalvah 5 years ago
parent
commit
5d2be82a57
5 changed files with 11 additions and 22 deletions
  1. 4 0
      CHANGELOG.md
  2. 0 2
      TODO.md
  3. 2 1
      composer.json
  4. 4 18
      src/Tools/Utils.php
  5. 1 1
      tests/GenerateDocumentationTest.php

+ 4 - 0
CHANGELOG.md

@@ -13,6 +13,10 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
 
 ### Removed
 
+## [3.10.0] - Sunday, 23 June 2019
+### Added
+- `--verbose` flag to show exception encountered when making response call.
+
 ## [3.9.0] - Saturday, 8 June 2019
 ### Modified
 - Postman collections and URLs in example requests now use the `apidoc.base_url` config variable (https://github.com/mpociot/laravel-apidoc-generator/pull/523)

+ 0 - 2
TODO.md

@@ -1,5 +1,3 @@
-- Replace filesystem manipulation with lib
-
 Major
 - Bring `bindings` outside of `response_calls`
 - Should `routes.*.apply.response_calls.headers` be replaced by `routes.*.apply.headers`?

+ 2 - 1
composer.json

@@ -23,7 +23,8 @@
         "mpociot/documentarian": "^0.2.0",
         "mpociot/reflection-docblock": "^1.0.1",
         "ramsey/uuid": "^3.8",
-        "nunomaduro/collision": "^3.0"
+        "nunomaduro/collision": "^3.0",
+        "league/flysystem": "^1.0"
     },
     "require-dev": {
         "orchestra/testbench": "3.5.* || 3.6.* || 3.7.*",

+ 4 - 18
src/Tools/Utils.php

@@ -4,10 +4,8 @@ namespace Mpociot\ApiDoc\Tools;
 
 use Illuminate\Support\Str;
 use Illuminate\Routing\Route;
-use League\Flysystem\Adapter\Local;
 use League\Flysystem\Filesystem;
-use RecursiveDirectoryIterator;
-use RecursiveIteratorIterator;
+use League\Flysystem\Adapter\Local;
 
 class Utils
 {
@@ -70,20 +68,8 @@ class Utils
 
     public static function deleteDirectoryAndContents($dir)
     {
-        if (is_dir($dir)) {
-            $files = new RecursiveIteratorIterator(
-                new RecursiveDirectoryIterator($dir, RecursiveDirectoryIterator::SKIP_DOTS),
-                RecursiveIteratorIterator::CHILD_FIRST
-            );
-
-            foreach ($files as $fileinfo) {
-                $todo = ($fileinfo->isDir() ? 'rmdir' : 'unlink');
-                $todo($fileinfo->getRealPath());
-            }
-            rmdir($dir);
-        }
-        /*
-        $adapter = new Local(__DIR__.'../../');
-        $filesystem = new Filesystem($adapter);*/
+        $adapter = new Local(realpath(__DIR__."/../../"));
+        $fs = new Filesystem($adapter);
+        $fs->deleteDir($dir);
     }
 }

+ 1 - 1
tests/GenerateDocumentationTest.php

@@ -31,7 +31,7 @@ class GenerateDocumentationTest extends TestCase
 
     public function tearDown()
     {
-        Utils::deleteDirectoryAndContents(__DIR__.'/../public/docs');
+        Utils::deleteDirectoryAndContents('/public/docs');
     }
 
     /**