1
0
mirror of https://github.com/nicoverbruggen/phpmon.git synced 2025-08-07 12:00:09 +02:00

👌 Add system_quiet helper

This commit is contained in:
2023-01-31 18:06:47 +01:00
parent 3ceded3456
commit 7be6a335df
3 changed files with 22 additions and 4 deletions

View File

@ -91,7 +91,7 @@
</CommandLineArgument>
<CommandLineArgument
argument = "--cli"
isEnabled = "YES">
isEnabled = "NO">
</CommandLineArgument>
<CommandLineArgument
argument = "--configuration:~/.phpmon_fconf_working.json"

View File

@ -29,9 +29,9 @@ class Log {
public func prepareLogFile() {
if !isRunningTests && Verbosity.cli.isApplicable() {
_ = system("mkdir -p ~/.config/phpmon 2> /dev/null")
_ = system("rm ~/.config/phpmon/last_session.log 2> /dev/null")
_ = system("touch ~/.config/phpmon/last_session.log 2> /dev/null")
system_quiet("mkdir -p ~/.config/phpmon 2> /dev/null")
system_quiet("rm ~/.config/phpmon/last_session.log 2> /dev/null")
system_quiet("touch ~/.config/phpmon/last_session.log 2> /dev/null")
self.logExists = FileSystem.fileExists(self.logFilePath)
}
}

View File

@ -26,3 +26,21 @@ public func system(_ command: String) -> String {
return output
}
/**
Run a simple blocking Shell command on the user's own system.
This variation does not return the output.
Avoid using this method in favor of the fakeable Shell class unless needed for express system operations.
*/
public func system_quiet(_ command: String) {
let task = Process()
task.launchPath = "/bin/sh"
task.arguments = ["-c", command]
let pipe = Pipe()
task.standardOutput = pipe
task.launch()
_ = pipe.fileHandleForReading.readDataToEndOfFile()
return
}