cmd/lib/check.rb: skip apple system launchjobs (#123352)

* cmd/lib/check.rb: skip apple system launchjobs

* use constant for repeated regex
This commit is contained in:
Bevan Kay
2022-05-12 13:02:08 +08:00
committed by GitHub
parent b2dcc44d5b
commit 5118bdc5c6
+5 -1
View File
@@ -1,6 +1,9 @@
# typed: false
# frozen_string_literal: true
require "forwardable"
APPLE_LAUNCHJOBS_REGEX =
/\A(?:application\.)?com\.apple\.(installer|Safari|systemevents|systempreferences)(?:\.|$)/.freeze
module Check
CHECKS = {
@@ -48,7 +51,7 @@ module Check
system_command!("/bin/launchctl", args: ["list"], print_stderr: false, sudo: sudo)
.stdout
.lines.drop(1)
.grep_v(/\A(?:application\.)?com\.apple\.(installer|Safari|systemevents|systempreferences)(?:\.|$)/)
.grep_v(APPLE_LAUNCHJOBS_REGEX)
end
[false, true]
@@ -124,6 +127,7 @@ module Check
running_apps = diff[:loaded_launchjobs]
.added
.grep(/\.\d+\Z/)
.grep_v(APPLE_LAUNCHJOBS_REGEX)
.map { |id| id.sub(/\A(?:application\.)?(.*?)(?:\.\d+){0,2}\Z/, '\1') }
loaded_launchjobs = diff[:loaded_launchjobs]