Skip to content

Commit

Permalink
feat: support json5 config format
Browse files Browse the repository at this point in the history
I love comments in json, this is going to be awesome
  • Loading branch information
iloveitaly committed May 19, 2023
1 parent 3dd5a4b commit 7add980
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 2 deletions.
2 changes: 1 addition & 1 deletion Package.swift
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ import PackageDescription
let package = Package(
name: "hyper-focus",
platforms: [
.macOS(.v10_15),
.macOS(.v12),
],
dependencies: [
.package(url: "https://github.com/envoy/Ambassador", from: "4.0.0"),
Expand Down
8 changes: 7 additions & 1 deletion Sources/hyper-focus/configuration_loader.swift
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,13 @@ enum ConfigurationLoader {
debug("Loading configuration from \(configPath!.absoluteString)")

let configData = try! Data(contentsOf: configPath!)
let config = try! JSONDecoder().decode(Configuration.self, from: configData)

// neat! Apple supports JSON5, which allows for comments
// https://developer.apple.com/documentation/foundation/jsondecoder/3766916-allowsjson5
let decoder = JSONDecoder()
decoder.allowsJSON5 = true

let config = try! decoder.decode(Configuration.self, from: configData)

return config
}
Expand Down

0 comments on commit 7add980

Please sign in to comment.