Make everything else work on Linux

This commit is contained in:
Sami Samhuri 2019-12-22 13:46:29 -08:00
parent 6a0db8febe
commit b28b52d75d
5 changed files with 8 additions and 3 deletions

View file

@ -72,7 +72,11 @@ final class JSONFeedWriter {
) )
let encoder = JSONEncoder() let encoder = JSONEncoder()
encoder.dateEncodingStrategy = .iso8601 encoder.dateEncodingStrategy = .iso8601
#if os(Linux)
encoder.outputFormatting = [.prettyPrinted]
#else
encoder.outputFormatting = [.prettyPrinted, .withoutEscapingSlashes] encoder.outputFormatting = [.prettyPrinted, .withoutEscapingSlashes]
#endif
let feedJSON = try encoder.encode(feed) let feedJSON = try encoder.encode(feed)
let feedURL = targetURL.appendingPathComponent(jsonFeed.path) let feedURL = targetURL.appendingPathComponent(jsonFeed.path)
try feedJSON.write(to: feedURL, options: [.atomic]) try feedJSON.write(to: feedURL, options: [.atomic])

View file

@ -79,7 +79,7 @@ final class PostRepo {
return try fileManager.contentsOfDirectory(atPath: directory.path).flatMap { (filename: String) -> [URL] in return try fileManager.contentsOfDirectory(atPath: directory.path).flatMap { (filename: String) -> [URL] in
let fileURL = directory.appendingPathComponent(filename) let fileURL = directory.appendingPathComponent(filename)
var isDir: ObjCBool = false var isDir: ObjCBool = false
fileManager.fileExists(atPath: fileURL.path, isDirectory: &isDir) _ = fileManager.fileExists(atPath: fileURL.path, isDirectory: &isDir)
if isDir.boolValue { if isDir.boolValue {
return try enumerateMarkdownFiles(directory: fileURL) return try enumerateMarkdownFiles(directory: fileURL)
} }

View file

@ -49,7 +49,7 @@ public final class SiteGenerator {
// Recurse into subdirectories, updating the target directory as well. // Recurse into subdirectories, updating the target directory as well.
let fileURL = URL(fileURLWithPath: path).appendingPathComponent(filename) let fileURL = URL(fileURLWithPath: path).appendingPathComponent(filename)
var isDir: ObjCBool = false var isDir: ObjCBool = false
fileManager.fileExists(atPath: fileURL.path, isDirectory: &isDir) _ = fileManager.fileExists(atPath: fileURL.path, isDirectory: &isDir)
guard !isDir.boolValue else { guard !isDir.boolValue else {
try renderPath(fileURL.path, to: targetURL.appendingPathComponent(filename)) try renderPath(fileURL.path, to: targetURL.appendingPathComponent(filename))
continue continue

View file

@ -1,5 +1,7 @@
#!/bin/bash #!/bin/bash
set -euo pipefail
if [[ $(uname) = "Linux" ]]; then if [[ $(uname) = "Linux" ]]; then
build_platform_dir="x86_64-unknown-linux" build_platform_dir="x86_64-unknown-linux"
else else

View file

@ -5,7 +5,6 @@
// Created by Sami Samhuri on 2019-12-01. // Created by Sami Samhuri on 2019-12-01.
// //
import Darwin
import Foundation import Foundation
import samhuri_net import samhuri_net