From 9bcdb16b3b9a0ec61a8f29c6d595c6280df87e66 Mon Sep 17 00:00:00 2001 From: yqrashawn Date: Sun, 17 Jul 2022 17:01:19 +0800 Subject: [PATCH] fix: finding PATH, use direnv BREAKING CHANGE: use $SHELL -i -c to run joker --- .envrc | 1 + CHANGELOG.org | 10 +++++++++- deps.edn | 2 +- project.clj | 7 ++----- src/karabiner_configurator/core.clj | 23 +++++++---------------- src/karabiner_configurator/misc.clj | 5 ++--- 6 files changed, 22 insertions(+), 26 deletions(-) create mode 100644 .envrc diff --git a/.envrc b/.envrc new file mode 100644 index 0000000..c0647ad --- /dev/null +++ b/.envrc @@ -0,0 +1 @@ +export GOKU_IS_DEV=1 diff --git a/CHANGELOG.org b/CHANGELOG.org index cf13e04..4be6f3f 100644 --- a/CHANGELOG.org +++ b/CHANGELOG.org @@ -3,7 +3,15 @@ All notable changes to this project will be documented in this file. This change ** Unreleased -[Unreleased Commits]: https://github.com/yqrashawn/GokuRakuJoudo/compare/v0.5.6...HEAD +[Unreleased Commits]: https://github.com/yqrashawn/GokuRakuJoudo/compare/v0.6.0..HEAD + +** 0.6.0 - 2022-07-17 +*** Fixed +- BREAKING remove deps on ~watchexec~ (gokuw still use ~watchexec~) +- BREAKING use $SHELL -i -c to run joker +- fix brew service + +[commits in 0.6.0]: https://github.com/yqrashawn/GokuRakuJoudo/compare/v0.5.6...v0.6.0 ** 0.5.6 - 2022-07-17 *** Added diff --git a/deps.edn b/deps.edn index 3e57730..3fd0072 100644 --- a/deps.edn +++ b/deps.edn @@ -2,5 +2,5 @@ org.clojure/tools.cli {:mvn/version "1.0.206"} me.raynes/fs {:mvn/version "1.4.6"} cheshire/cheshire {:mvn/version "5.10.2"} - environ/environ {:mvn/version "1.2.0"} + babashka/process {:mvn/version "0.1.7"} com.github.clj-easy/graal-build-time {:mvn/version "0.1.4"}}} diff --git a/project.clj b/project.clj index 10a0ce3..16b5615 100644 --- a/project.clj +++ b/project.clj @@ -8,12 +8,9 @@ :dependencies [[org.clojure/clojure "1.11.1"] [org.clojure/tools.cli "1.0.206"] [me.raynes/fs "1.4.6"] + [babashka/process "0.1.7"] [cheshire "5.10.2"] - [environ "1.2.0"] [com.github.clj-easy/graal-build-time "0.1.4"]] - :plugins [[lein-cloverage "1.2.3"] - [lein-environ "1.2.0"]] - :profiles {:dev {:env {:is-dev true}} - :test {:env {:is-dev true}}}) + :plugins [[lein-cloverage "1.2.3"]]) diff --git a/src/karabiner_configurator/core.clj b/src/karabiner_configurator/core.clj index 9807194..a15fe53 100644 --- a/src/karabiner_configurator/core.clj +++ b/src/karabiner_configurator/core.clj @@ -1,10 +1,9 @@ (ns karabiner-configurator.core (:require + [babashka.process :as p] [cheshire.core :as json] - [clojure.java.shell :as shell] [clojure.string :as string] [clojure.tools.cli :as cli] - [environ.core :refer [env]] [karabiner-configurator.data :as d] [karabiner-configurator.froms :as froms] [karabiner-configurator.layers :as layers] @@ -26,22 +25,14 @@ (defn check-edn-syntax "Call joker to check syntax of karabiner.edn" [path] - (let [sys-env (into {} (System/getenv))] - (shell/sh "joker" "--lint" path - :env (merge - sys-env - {"PATH" - (str "/etc/profiles/per-user/" (System/getenv "USER") "/bin:" ;; nix profile - "/run/current-system/sw/bin:" ;; nix darwin multiuser - "/opt/homebrew/bin:" ;; arm homebrew - "/usr/local/bin:" ;; homebrew - (get sys-env "PATH"))})))) + (-> @(p/process [(System/getenv "SHELL") "-i" "-c" (format "joker --lint %s" path)]) + :err)) (defn exit ([status] (exit [status nil])) ([status msg] (when msg (println msg)) - (when-not (env :is-dev) (System/exit status)))) + (when-not (= (System/getenv "GOKU_IS_DEV") "1") (System/exit status)))) ;; paths (defn json-config-file-path @@ -147,9 +138,9 @@ (update-to-karabiner-json (parse-edn (load-edn path)) dry-run dry-run-all)) (defn open-log-file [] - (shell/sh "open" (log-file))) -;; cli stuff + @(p/process "open" (log-file))) +;; cli stuff (defn help-message [_] (->> ["GokuRakuJoudo -- karabiner configurator" "" @@ -210,7 +201,7 @@ (:version options) {:action "exit-with-message" :ok? true - :exit-message "0.5.6"} + :exit-message "0.5.7"} ;; log (:log options) {:action "log" diff --git a/src/karabiner_configurator/misc.clj b/src/karabiner_configurator/misc.clj index a057d5c..7d0dabc 100644 --- a/src/karabiner_configurator/misc.clj +++ b/src/karabiner_configurator/misc.clj @@ -1,14 +1,13 @@ (ns karabiner-configurator.misc (:require [cheshire.core :as json] [clojure.edn :as edn] - [clojure.java.io :as io] - [environ.core :refer [env]])) + [clojure.java.io :as io])) (defn massert "Assert without stacktrace" [exp error-str] (let [error-str (str "ERROR: " error-str)] - (if (env :is-dev) + (if (= (System/getenv "GOKU_IS_DEV") "1") (assert exp error-str) (try (assert exp error-str)