Skip to content

Commit db6d5bc

Browse files
committed
Prevent creation of empty directories in merge
1 parent 9f1c096 commit db6d5bc

File tree

2 files changed

+9
-8
lines changed

2 files changed

+9
-8
lines changed

Sources/SwiftDocCUtilities/Action/Actions/Merge/MergeAction.swift

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -65,6 +65,8 @@ struct MergeAction: AsyncAction {
6565
let fromDirectory = archive.appendingPathComponent(directoryToCopy, isDirectory: true)
6666
let toDirectory = targetURL.appendingPathComponent(directoryToCopy, isDirectory: true)
6767

68+
guard fileManager.directoryExists(atPath: fromDirectory.path) else { continue }
69+
6870
// Ensure that the destination directory exist in case the first archive didn't have that kind of pages.
6971
// This is necessary when merging a reference-only archive with a tutorial-only archive.
7072
try? fileManager.createDirectory(at: toDirectory, withIntermediateDirectories: false, attributes: nil)

Tests/SwiftDocCUtilitiesTests/MergeActionTests.swift

Lines changed: 7 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -996,14 +996,13 @@ class MergeActionTests: XCTestCase {
996996
Output.doccarchive/
997997
├─ data/
998998
│ ├─ documentation.json
999-
│ ├─ documentation/
1000-
│ │ ├─ first.json
1001-
│ │ ├─ first/
1002-
│ │ │ ╰─ article.json
1003-
│ │ ├─ second.json
1004-
│ │ ╰─ second/
1005-
│ │ ╰─ article.json
1006-
│ ╰─ tutorials/
999+
│ ╰─ documentation/
1000+
│ ├─ first.json
1001+
│ ├─ first/
1002+
│ │ ╰─ article.json
1003+
│ ├─ second.json
1004+
│ ╰─ second/
1005+
│ ╰─ article.json
10071006
├─ downloads/
10081007
│ ├─ First/
10091008
│ ╰─ Second/

0 commit comments

Comments
 (0)