Skip to content

Commit

Permalink
Fix directory deletion
Browse files Browse the repository at this point in the history
  • Loading branch information
shalvah committed Jun 25, 2021
1 parent b114623 commit 8b93252
Show file tree
Hide file tree
Showing 3 changed files with 23 additions and 8 deletions.
9 changes: 6 additions & 3 deletions src/Writing/HtmlWriter.php
Original file line number Diff line number Diff line change
Expand Up @@ -62,9 +62,12 @@ public function generate(array $groupedEndpoints, string $sourceFolder, string $

// Copy assets
$assetsFolder = __DIR__ . '/../../resources';
if (is_dir($assetsFolder)) {
// Prune older versioned assets
Utils::deleteDirectoryAndContents($assetsFolder);
// Prune older versioned assets
if (is_dir($destinationFolder.'/css')) {
Utils::deleteDirectoryAndContents($destinationFolder.'/css');
}
if (is_dir($destinationFolder.'/js')) {
Utils::deleteDirectoryAndContents($destinationFolder.'/js');
}
Utils::copyDirectory("{$assetsFolder}/images/", "{$destinationFolder}/images");

Expand Down
16 changes: 14 additions & 2 deletions tests/Fixtures/openapi.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -291,8 +291,20 @@ paths:
type: array
description: Details.
example:
- [ ]
- [ ]
- first_name: 'John'
last_name: 'Doe'
contacts:
- first_name: Janelle
last_name: Monáe
- {}
roles: [Admin]
- first_name: 'John'
last_name: 'Doe'
contacts:
- first_name: Janelle
last_name: Monáe
- {}
roles: [Admin]
items:
type: object
properties:
Expand Down
6 changes: 3 additions & 3 deletions tests/GenerateDocumentationTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -260,9 +260,9 @@ public function generated_openapi_spec_file_is_correct()

$this->artisan('scribe:generate');

$generatedCollection = Yaml::parseFile(__DIR__ . '/../public/docs/openapi.yaml');
$fixtureCollection = Yaml::parseFile(__DIR__ . '/Fixtures/openapi.yaml');
$this->assertEquals($fixtureCollection, $generatedCollection);
$generatedSpec = Yaml::parseFile(__DIR__ . '/../public/docs/openapi.yaml');
$fixtureSpec = Yaml::parseFile(__DIR__ . '/Fixtures/openapi.yaml');
$this->assertEquals($fixtureSpec, $generatedSpec);
}

/** @test */
Expand Down

0 comments on commit 8b93252

Please sign in to comment.