mirror of
https://github.com/nicoverbruggen/phpmon.git
synced 2025-08-08 04:20:07 +02:00
This also moves the location of the .phpmon.conf.json file to a new location: ~/.config/phpmon/config.json.
38 lines
850 B
Swift
38 lines
850 B
Swift
//
|
|
// PresetHelper.swift
|
|
// PHP Monitor
|
|
//
|
|
// Created by Nico Verbruggen on 02/06/2022.
|
|
// Copyright © 2022 Nico Verbruggen. All rights reserved.
|
|
//
|
|
|
|
import Foundation
|
|
|
|
class PresetHelper {
|
|
|
|
static var rollbackPreset: Preset?
|
|
|
|
// MARK: - Reloading Configuration
|
|
|
|
public static func loadRollbackPresetFromFile() {
|
|
guard let revert = try? String(
|
|
contentsOfFile: "/Users/\(Paths.whoami)/.config/phpmon/preset_revert.json",
|
|
encoding: .utf8
|
|
) else {
|
|
PresetHelper.rollbackPreset = nil
|
|
return
|
|
}
|
|
|
|
guard let preset = try? JSONDecoder().decode(
|
|
Preset.self,
|
|
from: revert.data(using: .utf8)!
|
|
) else {
|
|
PresetHelper.rollbackPreset = nil
|
|
return
|
|
}
|
|
|
|
PresetHelper.rollbackPreset = preset
|
|
}
|
|
|
|
}
|