Skip to content

Commit

Permalink
fix: read file relative to current directory
Browse files Browse the repository at this point in the history
  • Loading branch information
socsieng committed Dec 31, 2020
1 parent 6d4a847 commit 49e1253
Showing 1 changed file with 5 additions and 5 deletions.
10 changes: 5 additions & 5 deletions Sources/SendKeysLib/SendKeysCli.swift
Expand Up @@ -40,11 +40,11 @@ public struct SendKeysCli: ParsableCommand {
var commandString: String?

if !(inputFile ?? "").isEmpty {
let directoryUrl = FileManager.default.urls(for: .documentDirectory, in: .userDomainMask)[0]
let fileUrl = URL(fileURLWithPath: inputFile!, relativeTo: directoryUrl)

let data = try! Data(contentsOf: fileUrl)
commandString = String(data: data, encoding: .utf8)
if let data = FileManager.default.contents(atPath: inputFile!) {
commandString = String(data: data, encoding: .utf8)
} else {
fatalError("Could not read file \(inputFile!)")
}
} else if !(characters ?? "").isEmpty {
commandString = characters
}
Expand Down

0 comments on commit 49e1253

Please sign in to comment.