1
0
mirror of https://github.com/nicoverbruggen/phpmon.git synced 2025-11-09 13:10:24 +01:00

👌 Cleanup

This commit is contained in:
2021-05-07 15:29:47 +02:00
parent b072ee8dec
commit f881f07cba
2 changed files with 16 additions and 12 deletions

View File

@@ -61,6 +61,7 @@ class PhpExtension {
let fullPath = String(line[range]) let fullPath = String(line[range])
.replacingOccurrences(of: "\"", with: "") // replace excess " .replacingOccurrences(of: "\"", with: "") // replace excess "
.replacingOccurrences(of: ".so", with: "") // replace excess .so .replacingOccurrences(of: ".so", with: "") // replace excess .so
self.name = String(fullPath.split(separator: "/").last!) // take last segment self.name = String(fullPath.split(separator: "/").last!) // take last segment
self.enabled = !line.contains(";") self.enabled = !line.contains(";")
@@ -71,12 +72,15 @@ class PhpExtension {
This simply toggles the extension in the .ini file. You may need to restart the other services in order for this change to apply. This simply toggles the extension in the .ini file. You may need to restart the other services in order for this change to apply.
*/ */
func toggle() { func toggle() {
Actions.sed( let newLine = enabled
file: file, // DISABLED: Commented out line
original: line, ? "; \(line)"
replacement: enabled ? "; \(line)" : line.replacingOccurrences(of: "; ", with: "") // ENABLED: Line where the comment delimiter (;) is removed
) : line.replacingOccurrences(of: "; ", with: "")
enabled = !enabled
Actions.sed(file: file, original: line, replacement: newLine)
enabled.toggle()
} }
// MARK: - Static Methods // MARK: - Static Methods
@@ -93,11 +97,11 @@ class PhpExtension {
} }
return file!.components(separatedBy: "\n") return file!.components(separatedBy: "\n")
.filter({ (line) -> Bool in .filter {
return line.range(of: Self.extensionRegex, options: .regularExpression) != nil return $0.range(of: Self.extensionRegex, options: .regularExpression) != nil
}) }
.map { (line) -> PhpExtension in .map {
return PhpExtension(line, file: path.path) return PhpExtension($0, file: path.path)
} }
} }
} }

View File

@@ -34,7 +34,7 @@ class Command {
.joined(separator: "\n") .joined(separator: "\n")
} }
return output; return output
} }
} }