From 9c19e5419d5197d3d3eb449e02b6d71a0c5b681e Mon Sep 17 00:00:00 2001 From: dsx Date: Wed, 28 Aug 2024 19:22:44 -0400 Subject: [PATCH 1/2] Allow passing extra arguments to Chrome binary --- src/clj_chrome_devtools/automation/launcher.clj | 15 ++++++++------- 1 file changed, 8 insertions(+), 7 deletions(-) diff --git a/src/clj_chrome_devtools/automation/launcher.clj b/src/clj_chrome_devtools/automation/launcher.clj index b3dda83..cc3acaf 100644 --- a/src/clj_chrome_devtools/automation/launcher.clj +++ b/src/clj_chrome_devtools/automation/launcher.clj @@ -40,13 +40,14 @@ (log/trace "Launching Chrome headless, binary: " binary-path ", remote debugging port: " remote-debugging-port ", options: " (pr-str options)) - (let [args (remove nil? - [binary-path - (when (:headless? options) "--headless") - (when (:no-sandbox? options) "--no-sandbox") - "--disable-gpu" - (str "--remote-debugging-port=" remote-debugging-port) - (when-let [url (:url-to-open options)] (str url))])] + (let [args (->> [binary-path + (when (:headless? options) "--headless") + (when (:no-sandbox? options) "--no-sandbox") + (when-not (:enable-gpu? options) "--disable-gpu") + (str "--remote-debugging-port=" remote-debugging-port) + (:args options)] + flatten + (remove nil?))] (.exec (Runtime/getRuntime) ^"[Ljava.lang.String;" (into-array String args)))) From 89677ff3d542ddc075705559be1eee203f958be2 Mon Sep 17 00:00:00 2001 From: user Date: Fri, 13 Sep 2024 17:26:49 -0400 Subject: [PATCH 2/2] Use concat instead of flatten --- src/clj_chrome_devtools/automation/launcher.clj | 14 ++++++-------- 1 file changed, 6 insertions(+), 8 deletions(-) diff --git a/src/clj_chrome_devtools/automation/launcher.clj b/src/clj_chrome_devtools/automation/launcher.clj index cc3acaf..8428cff 100644 --- a/src/clj_chrome_devtools/automation/launcher.clj +++ b/src/clj_chrome_devtools/automation/launcher.clj @@ -40,14 +40,12 @@ (log/trace "Launching Chrome headless, binary: " binary-path ", remote debugging port: " remote-debugging-port ", options: " (pr-str options)) - (let [args (->> [binary-path - (when (:headless? options) "--headless") - (when (:no-sandbox? options) "--no-sandbox") - (when-not (:enable-gpu? options) "--disable-gpu") - (str "--remote-debugging-port=" remote-debugging-port) - (:args options)] - flatten - (remove nil?))] + (let [args (remove nil? (concat [binary-path + (when (:headless? options) "--headless") + (when (:no-sandbox? options) "--no-sandbox") + (when-not (:enable-gpu? options) "--disable-gpu") + (str "--remote-debugging-port=" remote-debugging-port)] + (:args options)))] (.exec (Runtime/getRuntime) ^"[Ljava.lang.String;" (into-array String args))))