Skip to content

Commit

Permalink
fix: 优化空目录检查逻辑并添加相应测试
Browse files Browse the repository at this point in the history
  • Loading branch information
TBXark committed Jan 21, 2025
1 parent 1b151f8 commit 734eec0
Show file tree
Hide file tree
Showing 3 changed files with 6 additions and 9 deletions.
9 changes: 4 additions & 5 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -20,13 +20,12 @@ build:
# install config in brew formula
# bin.install ".build/release/rmtrash"


.PHONY: manual
manual:
swift package generate-manual
# install config in brew formula
# man1.install ".build/plugins/GenerateManual/outputs/rmtrash/rmtrash.1"
cp .build/plugins/GenerateManual/outputs/rmtrash/rmtrash.1 Manual/rmtrash.1
cp .build/plugins/GenerateManual/outputs/$(bin)/$(bin).1 Manual/$(bin).1

.PHONY: build-universal
build-universal:
Expand All @@ -37,9 +36,9 @@ build-universal:
.PHONY: release
release: test build-universal manual
mkdir -p .dist
cp .build/plugins/GenerateManual/outputs/rmtrash/rmtrash.1 .build/x86_64-apple-macosx/release
cp .build/plugins/GenerateManual/outputs/rmtrash/rmtrash.1 .build/arm64-apple-macosx/release
cp .build/plugins/GenerateManual/outputs/rmtrash/rmtrash.1 .build/release
cp .build/plugins/GenerateManual/outputs/$(bin)/$(bin).1 .build/x86_64-apple-macosx/release
cp .build/plugins/GenerateManual/outputs/$(bin)/$(bin).1 .build/arm64-apple-macosx/release
cp .build/plugins/GenerateManual/outputs/$(bin)/$(bin).1 .build/release
tar -czf .dist/$(bin)_$(version)_x86_64.tar.gz -C .build/x86_64-apple-macosx/release $(bin) $(bin).1
tar -czf .dist/$(bin)_$(version)_arm64.tar.gz -C .build/arm64-apple-macosx/release $(bin) $(bin).1
tar -czf .dist/$(bin)_$(version)_universal.tar.gz -C .build/release $(bin) $(bin).1
Expand Down
5 changes: 1 addition & 4 deletions Sources/rmtrash/rmtrash.swift
Original file line number Diff line number Diff line change
Expand Up @@ -116,10 +116,7 @@ extension FileManager: FileManagerType {
guard let enumerator = enumerator(at: url, includingPropertiesForKeys: nil, options: []) else {
return true
}
for _ in enumerator {
return false
}
return true
return enumerator.nextObject() == nil
}

public func isCrossMountPoint(_ url: URL) throws -> Bool {
Expand Down
1 change: 1 addition & 0 deletions Tests/rmtrashTests/rmtrashTests.swift
Original file line number Diff line number Diff line change
Expand Up @@ -214,6 +214,7 @@ final class RmTrashTests: XCTestCase {
question: StaticAnswer(value: true)
)
XCTAssertTrue(yesTrash.removeMultiple(paths: ["./test1.txt", "./dir1"]))
XCTAssertTrue(fileManager.isEmptyDirectory(url))
assertFileStructure(fileManager, at: url, expectedFiles: [])
}

Expand Down

0 comments on commit 734eec0

Please sign in to comment.