Skip to content
This repository has been archived by the owner on Oct 17, 2021. It is now read-only.

Commit

Permalink
Rename executable to swift-syntax-highlight
Browse files Browse the repository at this point in the history
  • Loading branch information
mattt committed Dec 2, 2018
1 parent 8b8aa7e commit 3cbabe4
Show file tree
Hide file tree
Showing 3 changed files with 5 additions and 5 deletions.
2 changes: 1 addition & 1 deletion Package.swift
Expand Up @@ -17,7 +17,7 @@ let package = Package(
// Targets can depend on other targets in this package,
// and on products in packages which this package depends on.
.target(
name: "Highlight",
name: "swift-syntax-highlight",
dependencies: ["SwiftSyntaxHighlighter"]),
.target(
name: "SwiftSyntaxHighlighter",
Expand Down
4 changes: 2 additions & 2 deletions Sources/SwiftSyntaxHighlighter/SwiftSyntaxHighlighter.swift
Expand Up @@ -11,7 +11,7 @@ class SwiftSyntaxHighlighter: SyntaxRewriter {
public var html: String {
return "<pre class=\"highlight\"><code>\(highlightTokens.compactMap { $0?.html }.joined())</code></pre>"
}

override func visit(_ token: TokenSyntax) -> Syntax {
defer { previousToken = token }

Expand Down Expand Up @@ -226,7 +226,7 @@ public func highlight(_ code: String) throws -> String {
let tempfile = try TemporaryFile(deleteOnClose: true)
defer { tempfile.fileHandle.closeFile() }
tempfile.fileHandle.write(code.data(using: .utf8)!)

let url = URL(fileURLWithPath: tempfile.path.asString)
return try highlight(url)
}
Expand Down
Expand Up @@ -15,7 +15,7 @@ let stderr = FileHandle.standardError
do {
let arguments = Array(ProcessInfo.processInfo.arguments.dropFirst())
let parsedArguments = try parser.parse(arguments)

var output: String
let input = parsedArguments.get(inputArgument)!
if FileManager.default.fileExists(atPath: input) {
Expand All @@ -24,7 +24,7 @@ do {
} else {
output = try highlight(input)
}

stdout.write(output.data(using: .utf8)!)
} catch let error as ArgumentParserError {
stderr.write(error.description.data(using: .utf8)!)
Expand Down

0 comments on commit 3cbabe4

Please sign in to comment.