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:
@ -91,7 +91,7 @@
|
||||
</CommandLineArgument>
|
||||
<CommandLineArgument
|
||||
argument = "--cli"
|
||||
isEnabled = "YES">
|
||||
isEnabled = "NO">
|
||||
</CommandLineArgument>
|
||||
<CommandLineArgument
|
||||
argument = "--configuration:~/.phpmon_fconf_working.json"
|
||||
|
@ -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)
|
||||
}
|
||||
}
|
||||
|
@ -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
|
||||
}
|
||||
|
Reference in New Issue
Block a user