From 1d482244e521e0ad8d7bfc3faa758fa3e36eb372 Mon Sep 17 00:00:00 2001 From: Mike McQuaid Date: Wed, 6 Aug 2025 16:09:39 +0100 Subject: [PATCH] service: ensure JSON cron output can be `null`. This better matches other field and existing behaviour. --- Library/Homebrew/service.rb | 6 +++--- Library/Homebrew/services/formula_wrapper.rb | 2 +- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/Library/Homebrew/service.rb b/Library/Homebrew/service.rb index e39192990d..3fb072d945 100644 --- a/Library/Homebrew/service.rb +++ b/Library/Homebrew/service.rb @@ -529,9 +529,9 @@ module Homebrew return { name: name_params }.compact_blank if @run_params.blank? - cron_string = unless @cron.empty? + cron_string = if @cron.present? [:Minute, :Hour, :Day, :Month, :Weekday] - .map { |key| @cron[key].to_s } + .filter_map { |key| @cron[key].to_s.presence } .join(" ") end @@ -555,7 +555,7 @@ module Homebrew run: @run_params, run_type: @run_type, interval: @interval, - cron: cron_string, + cron: cron_string.presence, keep_alive: @keep_alive, launch_only_once: @launch_only_once, require_root: @require_root, diff --git a/Library/Homebrew/services/formula_wrapper.rb b/Library/Homebrew/services/formula_wrapper.rb index 834e6a815b..c8539c52da 100644 --- a/Library/Homebrew/services/formula_wrapper.rb +++ b/Library/Homebrew/services/formula_wrapper.rb @@ -227,7 +227,7 @@ module Homebrew hash[:log_path] = service.log_path hash[:error_log_path] = service.error_log_path hash[:interval] = service.interval - hash[:cron] = service.cron + hash[:cron] = service.cron.presence hash end