Skip to content

Commit 12d2ec8

Browse files
committed
remove files dep
1 parent a5fdbae commit 12d2ec8

File tree

3 files changed

+7
-21
lines changed

3 files changed

+7
-21
lines changed

Package.resolved

-9
Original file line numberDiff line numberDiff line change
@@ -1,15 +1,6 @@
11
{
22
"object": {
33
"pins": [
4-
{
5-
"package": "Files",
6-
"repositoryURL": "https://github.com/JohnSundell/Files",
7-
"state": {
8-
"branch": null,
9-
"revision": "d273b5b7025d386feef79ef6bad7de762e106eaf",
10-
"version": "4.2.0"
11-
}
12-
},
134
{
145
"package": "swift-argument-parser",
156
"repositoryURL": "https://github.com/apple/swift-argument-parser",

Package.swift

-2
Original file line numberDiff line numberDiff line change
@@ -9,15 +9,13 @@ let package = Package(
99
],
1010
dependencies: [
1111
.package(url: "https://github.com/jpsim/Yams.git", from: "4.0.0"),
12-
.package(url: "https://github.com/JohnSundell/Files", from: "4.0.0"),
1312
.package(url: "https://github.com/apple/swift-argument-parser", from: "1.0.2"),
1413
],
1514
targets: [
1615
.executableTarget(
1716
name: "downstream",
1817
dependencies: [
1918
.product(name: "Yams", package: "Yams"),
20-
.product(name: "Files", package: "Files"),
2119
.product(name: "ArgumentParser", package: "swift-argument-parser")
2220
],
2321
exclude: [

Sources/downstream/DownstreamArgument.swift

+7-10
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,5 @@
11
import ArgumentParser
22
import Foundation
3-
import Files
43
import Yams
54

65
enum OutputFormat: String, ExpressibleByArgument {
@@ -19,10 +18,6 @@ extension TodoList {
1918
}
2019
}
2120

22-
enum DownstreamError: Error {
23-
case fileNotFound(path: String)
24-
}
25-
2621
struct DownstreamArgument: ParsableCommand {
2722
@Option(name: .shortAndLong, help: "The format of the output")
2823
var outputFormat: OutputFormat = .humanFriendly
@@ -51,16 +46,18 @@ struct DownstreamArgument: ParsableCommand {
5146
return associationsFile.associations.matches(path)
5247
} else {
5348
// This path should be coming from git diff, so we expect it to be valid
54-
let changedFile = try! File(path: path)
49+
let changedFile = URL(fileURLWithPath: path)
50+
let parent = changedFile.deletingLastPathComponent()
51+
let downstreamYML = changedFile.appendingPathComponent("downstream.yml")
5552

5653
if
57-
let parent = changedFile.parent,
58-
let downsteamYML = try? parent.file(named: "downstream.yml").read()
54+
let contentData = FileManager.default.contents(atPath: downstreamYML.path),
55+
let associations = String(data: contentData, encoding: .utf8)
5956
{
60-
guard let associationsFile = try? decoder.decode(AssociationsFile.self, from: downsteamYML) else {
57+
guard let associationsFile = try? decoder.decode(AssociationsFile.self, from: associations) else {
6158
throw ValidationError("\(parent.path)downstream.yml could not be parsed")
6259
}
63-
let fileName = changedFile.name
60+
let fileName = changedFile.lastPathComponent
6461
return associationsFile.associations.matches(fileName)
6562
}
6663
}

0 commit comments

Comments
 (0)