Files
swift-hvac-toolbox/Sources/App/BrowserSync.swift

20 lines
493 B
Swift

import Foundation
import Vapor
#if DEBUG
struct BrowserSyncHandler: LifecycleHandler {
func didBoot(_ application: Application) throws {
if Environment.get("BROWSER_AUTO_RELOAD") != nil {
let process = Process()
process.executableURL = URL(filePath: "/bin/sh")
process.arguments = ["-c", "browser-sync reload"]
do {
try process.run()
} catch {
print("Could not auto-reload: \(error)")
}
}
}
}
#endif