Skip to content

Commit

Permalink
chore: add tools.io clj-kondo config
Browse files Browse the repository at this point in the history
  • Loading branch information
edporras committed Mar 14, 2024
1 parent f85a362 commit 23f9ddc
Show file tree
Hide file tree
Showing 2 changed files with 24 additions and 0 deletions.
2 changes: 2 additions & 0 deletions .clj-kondo/com.oscaro/tools.io/config.edn
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
{:hooks {:analyze-call {tools.io/with-tempdir hooks.io/with-tempdir
tools.io/with-tempfile hooks.io/with-tempfile}}}
22 changes: 22 additions & 0 deletions .clj-kondo/com.oscaro/tools.io/hooks/io.clj_kondo
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
(ns hooks.io
(:require [clj-kondo.hooks-api :as api]))

(defn- with-generated-string
[{:keys [:node]} *name]
(let [[name-in-list & body] (rest (:children node))]

(when-not (= 1 (count (:children name-in-list)))
(throw (ex-info (str *name " expects single argument") {})))
(let [n (first (:children name-in-list))
new-node (api/list-node
(list*
(api/token-node 'let)
(api/vector-node [n (api/string-node "tmp-name")])
body))]
{:node new-node})))

(defn with-tempdir [expr]
(with-generated-string expr "tempdir"))

(defn with-tempfile [expr]
(with-generated-string expr "tempfile"))

0 comments on commit 23f9ddc

Please sign in to comment.