Skip to content

Commit

Permalink
fix: overrides config with cli options (#566)
Browse files Browse the repository at this point in the history
  • Loading branch information
rafaeldelboni authored Oct 18, 2024
1 parent 07472c8 commit efba88a
Show file tree
Hide file tree
Showing 8 changed files with 54 additions and 8 deletions.
3 changes: 3 additions & 0 deletions .clj-kondo/http-kit/http-kit/config.edn
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@

{:hooks
{:analyze-call {org.httpkit.server/with-channel httpkit.with-channel/with-channel}}}
16 changes: 16 additions & 0 deletions .clj-kondo/http-kit/http-kit/httpkit/with_channel.clj
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
(ns httpkit.with-channel
(:require [clj-kondo.hooks-api :as api]))

(defn with-channel [{node :node}]
(let [[request channel & body] (rest (:children node))]
(when-not (and request channel) (throw (ex-info "No request or channel provided" {})))
(when-not (api/token-node? channel) (throw (ex-info "Missing channel argument" {})))
(let [new-node
(api/list-node
(list*
(api/token-node 'let)
(api/vector-node [channel (api/vector-node [])])
request
body))]

{:node new-node})))
5 changes: 5 additions & 0 deletions .clj-kondo/rewrite-clj/rewrite-clj/config.edn
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
{:lint-as
{rewrite-clj.zip/subedit-> clojure.core/->
rewrite-clj.zip/subedit->> clojure.core/->>
rewrite-clj.zip/edit-> clojure.core/->
rewrite-clj.zip/edit->> clojure.core/->>}}
1 change: 1 addition & 0 deletions .clj-kondo/taoensso/encore/config.edn
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
{:hooks {:analyze-call {taoensso.encore/defalias taoensso.encore/defalias}}}
16 changes: 16 additions & 0 deletions .clj-kondo/taoensso/encore/taoensso/encore.clj
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
(ns taoensso.encore
(:require
[clj-kondo.hooks-api :as hooks]))

(defn defalias [{:keys [node]}]
(let [[sym-raw src-raw] (rest (:children node))
src (if src-raw src-raw sym-raw)
sym (if src-raw
sym-raw
(symbol (name (hooks/sexpr src))))]
{:node (with-meta
(hooks/list-node
[(hooks/token-node 'def)
(hooks/token-node (hooks/sexpr sym))
(hooks/token-node (hooks/sexpr src))])
(meta src))}))
4 changes: 4 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,10 @@

[Squint](https://github.com/squint-cljs/squint): Light-weight ClojureScript dialect

## v0.8.121 (2024-10-18)

- Fix watcher & compiler not overriding `squint.edn` configurations with command line options.

## v0.8.120 (2024-10-18)

- Fix watcher not being called
Expand Down
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
"name": "squint-cljs",
"type": "module",
"sideEffects": false,
"version": "0.8.120",
"version": "0.8.121",
"files": [
"core.js",
"src/squint/core.js",
Expand Down
15 changes: 8 additions & 7 deletions src/squint/internal/cli.cljs
Original file line number Diff line number Diff line change
Expand Up @@ -68,9 +68,9 @@
[opts files]
(let [cfg @utils/!cfg
opts (merge cfg opts)
paths (:paths cfg)
copy-resources (:copy-resources cfg)
output-dir (:output-dir cfg ".")
paths (:paths opts)
copy-resources (:copy-resources opts)
output-dir (:output-dir opts ".")
files (if (empty? files)
(files-from-paths paths)
files)]
Expand All @@ -86,12 +86,13 @@
--elide-imports: do not include imports
--elide-exports: do not include exports
--extension: default extension for JS files
--paths: source paths to search for cljs/cljc files
--output-dir: output directory for JS files"))
(reduce (fn [prev f]
(-> (js/Promise.resolve prev)
(.then
#(do
(if (contains? #{".cljc" ".cljs"} (path/extname f ))
(if (contains? #{".cljc" ".cljs"} (path/extname f))
(do (println "[squint] Compiling CLJS file:" f)
(compiler/compile-file (assoc opts
:in-file f
Expand Down Expand Up @@ -184,9 +185,9 @@ Options:
(defn watch [opts]
(let [cfg @utils/!cfg
opts (merge cfg opts)
paths (:paths cfg)
output-dir (:output-dir cfg ".")
copy-resources (:copy-resources cfg)]
paths (:paths opts)
output-dir (:output-dir opts ".")
copy-resources (:copy-resources opts)]
(-> (-> (esm/dynamic-import "chokidar")
(.catch (fn [err]
(js/console.error err))))
Expand Down

0 comments on commit efba88a

Please sign in to comment.