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

cljr-add-missing-libspec doesn't clean namespace after adding spec #292

Closed
mbuczko opened this issue Feb 10, 2016 · 3 comments
Closed

cljr-add-missing-libspec doesn't clean namespace after adding spec #292

mbuczko opened this issue Feb 10, 2016 · 3 comments

Comments

@mbuczko
Copy link
Contributor

mbuczko commented Feb 10, 2016

I tried it few times on different sources and looks like cljr-clean-ns is not invoked after cljr-add-missing-libspec when cljr-auto-clean-ns is set to t.

let's look at following example:

(ns sample
  (:require [clojure.tools.logging :as log]
            [compojure.core :refer [GET]]))

(defn init-routes []
  (routes
    (GET "/index.html" [] (log/info "foo"))))

adding missing routes spec ends up with following ns:

(ns sample
  (:require [clojure.tools.logging :as log]
            [compojure.core :refer [GET]]
            [compojure.core :refer [routes]]))

and how it looks like after cleaning:

(ns sample
  (:require [clojure.tools.logging :as log]
            [compojure.core :refer [GET routes]]))
@expez
Copy link
Member

expez commented Feb 10, 2016

Ya, I see this too. Thanks for the report. cljr--maybe-clean-ns needs to be updated with a conditional flushing of the buffer to file. clean-ns acts on the file on disk and so doesn't see the unsaved changes just made to the ns form.

@mbuczko
Copy link
Contributor Author

mbuczko commented Feb 10, 2016

maybe this is also why sometimes libspec is not really added to ns (even though the the message says otherwise). invoking cljr-add-missing-libspec again mysteriously helps. I see it rarely and usually can't reproduce for a next few hours.

@expez
Copy link
Member

expez commented Feb 10, 2016

Yes, it will replace the ns form (but only if something's actually changed) while not knowing about the libspec that was just added.

@expez expez closed this as completed in 9806c5c Feb 11, 2016
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants