Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Search all forms in project.clj for defproject. #15

Merged
merged 1 commit into from
Sep 24, 2014
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
22 changes: 21 additions & 1 deletion src/leiningen/npm/deps.clj
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,24 @@
(keep (comp name :name))
(set))))

(defn- find-project-form
"Find the first form where the first element is the symbol defproject in the
given top-level forms."
[forms]
(letfn [(fpf [form]
(if (list? form)
(if (= 'defproject (first form))
form
(find-project-form form))))]
(->> forms
(map fpf)
(keep identity)
(first))))

(defn- read-project-form [input-stream]
(->> (str \( (slurp input-stream) \))
(read-string)
(find-project-form)))

(defn- resolve-in-jar-dep
"Resolves a given lookup-key in the project definiton in a given
Expand All @@ -43,7 +61,9 @@
[lookup-key exclusions jar-file]
(let [jar-project-entry (.getEntry jar-file "project.clj")
jar-project-src (when jar-project-entry
(read-string (slurp (.getInputStream jar-file jar-project-entry))))
(-> jar-file
(.getInputStream jar-project-entry)
(read-project-form)))
jar-project-map (when jar-project-src
(->> jar-project-src (drop 3) (apply hash-map)))
jar-project-name (when jar-project-src
Expand Down