Skip to content

Commit

Permalink
fix: finding PATH, use direnv
Browse files Browse the repository at this point in the history
BREAKING CHANGE: use $SHELL -i -c to run joker
  • Loading branch information
yqrashawn committed Jul 17, 2022
1 parent 3106498 commit 9bcdb16
Show file tree
Hide file tree
Showing 6 changed files with 22 additions and 26 deletions.
1 change: 1 addition & 0 deletions .envrc
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
export GOKU_IS_DEV=1
10 changes: 9 additions & 1 deletion CHANGELOG.org
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
2 changes: 1 addition & 1 deletion deps.edn
Original file line number Diff line number Diff line change
Expand Up @@ -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"}}}
7 changes: 2 additions & 5 deletions project.clj
Original file line number Diff line number Diff line change
Expand Up @@ -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"]])


23 changes: 7 additions & 16 deletions src/karabiner_configurator/core.clj
Original file line number Diff line number Diff line change
@@ -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]
Expand All @@ -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
Expand Down Expand Up @@ -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"
""
Expand Down Expand Up @@ -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"
Expand Down
5 changes: 2 additions & 3 deletions src/karabiner_configurator/misc.clj
Original file line number Diff line number Diff line change
@@ -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)
Expand Down

0 comments on commit 9bcdb16

Please sign in to comment.