mirror of
https://github.com/nicoverbruggen/phpmon.git
synced 2025-12-23 11:50:07 +01:00
👌 Use filesystem abstraction
This commit is contained in:
@@ -95,9 +95,7 @@ class Actions {
|
|||||||
// MARK: - Other Actions
|
// MARK: - Other Actions
|
||||||
|
|
||||||
public static func createTempPhpInfoFile() async -> URL {
|
public static func createTempPhpInfoFile() async -> URL {
|
||||||
// Write a file called `phpmon_phpinfo.php` to /tmp
|
try! FileSystem.writeAtomicallyToFile("/tmp/phpmon_phpinfo.php", content: "<?php phpinfo();")
|
||||||
// TODO: Use FileSystem abstraction
|
|
||||||
try! "<?php phpinfo();".write(toFile: "/tmp/phpmon_phpinfo.php", atomically: true, encoding: .utf8)
|
|
||||||
|
|
||||||
// Tell php-cgi to run the PHP and output as an .html file
|
// Tell php-cgi to run the PHP and output as an .html file
|
||||||
await Shell.quiet("\(Paths.binPath)/php-cgi -q /tmp/phpmon_phpinfo.php > /tmp/phpmon_phpinfo.html")
|
await Shell.quiet("\(Paths.binPath)/php-cgi -q /tmp/phpmon_phpinfo.php > /tmp/phpmon_phpinfo.html")
|
||||||
|
|||||||
@@ -35,8 +35,7 @@ class PhpConfigurationFile: CreatedFromFile {
|
|||||||
let path = filePath.replacingOccurrences(of: "~", with: Paths.homePath)
|
let path = filePath.replacingOccurrences(of: "~", with: Paths.homePath)
|
||||||
|
|
||||||
do {
|
do {
|
||||||
// TODO: Use FileSystem abstraction
|
let fileContents = try FileSystem.getStringFromFile(path)
|
||||||
let fileContents = try String(contentsOfFile: path)
|
|
||||||
return Self.init(path: path, contents: fileContents)
|
return Self.init(path: path, contents: fileContents)
|
||||||
} catch {
|
} catch {
|
||||||
Log.warn("Could not read the PHP configuration file at: `\(filePath)`")
|
Log.warn("Could not read the PHP configuration file at: `\(filePath)`")
|
||||||
|
|||||||
Reference in New Issue
Block a user