Skip to content

Commit

Permalink
Lexically normalize glob paths. Closes #425 (#449)
Browse files Browse the repository at this point in the history
  • Loading branch information
ileitch authored Dec 30, 2021
1 parent 523518b commit 42500fc
Show file tree
Hide file tree
Showing 3 changed files with 21 additions and 1 deletion.
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@
- Fix redundant public accessibility analysis of enum associated value types.
- Fix redundant public accessibility analysis of aliased types.
- Comment commands can now retain redundant protocols.
- Fix excluding paths that contain relative components, e.g `--report-exclude "../file.swift"`.

## 2.8.3 (2021-11-29)

Expand Down
2 changes: 1 addition & 1 deletion Sources/Shared/Extensions/FilePath+Glob.swift
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ public extension FilePath {
pattern: absolutePattern,
blacklistedDirectories: [".build", "node_modules"],
logger: inject()
).paths.map { FilePath($0) })
).paths.map { FilePath($0).lexicallyNormalized() })
}
}

Expand Down
19 changes: 19 additions & 0 deletions Tests/PeripheryTests/Extensions/FilePathGlobTest.swift
Original file line number Diff line number Diff line change
Expand Up @@ -101,6 +101,25 @@ class FilePathGlobTest : XCTestCase {
}
}

func testRelativeParent() {
FilePath("\(baseDir)/dir1").chdir() {
let pattern = "../bar"
let paths = FilePath.glob(pattern).sorted()
XCTAssertPathsEqual(paths, [
"\(baseDir)/bar"
])
}

FilePath("\(baseDir)/dir1/dir2").chdir() {
let pattern = "../../**/*.ext"
let paths = FilePath.glob(pattern).sorted()
XCTAssertPathsEqual(paths, [
"\(baseDir)/dir1/dir2/dir3/file2.ext",
"\(baseDir)/dir1/file1.ext"
])
}
}

// MARK: - Private

private func XCTAssertPathsEqual(_ filePaths: [FilePath], _ stringPaths: [String], file: StaticString = #file, line: UInt = #line) {
Expand Down

0 comments on commit 42500fc

Please sign in to comment.