fail cljs build on any warnings, eliminate warning about com.rpl.specter.transient namespace by renaming to transients

This commit is contained in:
Nathan Marz 2016-06-09 08:06:17 -04:00
parent 82144f6e4c
commit 4565a7e7d6
5 changed files with 13 additions and 95 deletions

View file

@ -46,4 +46,5 @@
:aliases {"cleantest" ["do" "clean," :aliases {"cleantest" ["do" "clean,"
"cljx" "once," "cljx" "once,"
"test"] "test"]
"deploy" ["do" "clean," "cljx" "once," "deploy" "clojars"]}) "deploy" ["do" "clean," "cljx" "once," "deploy" "clojars"]}
)

View file

@ -4,7 +4,15 @@
(cljs.build.api/build "target/classes/com/rpl" (cljs.build.api/build "target/classes/com/rpl"
{:output-to "out/main.js" {:output-to "out/main.js"
:verbose true}) :verbose true
:warning-handlers [(fn [warning-type env extra]
(when (warning-type cljs.analyzer/*cljs-warnings*)
(when-let [s (cljs.analyzer/error-message warning-type extra)]
(binding [*out* *err*]
(println "WARNING:" (cljs.analyzer/message env s))
(println "Failed to build because of warning!")
)
(System/exit 1))))]})
(cljs.repl/repl (cljs.repl.node/repl-env) (cljs.repl/repl (cljs.repl.node/repl-env)
:watch "target/classes/com/rpl" :watch "target/classes/com/rpl"

View file

@ -1,7 +1,7 @@
(ns com.rpl.specter.benchmarks (ns com.rpl.specter.benchmarks
(:use [com.rpl.specter] (:use [com.rpl.specter]
[com.rpl.specter macros] [com.rpl.specter macros]
[com.rpl.specter.transient] [com.rpl.specter.transients]
[com.rpl.specter.impl :only [benchmark]]) [com.rpl.specter.impl :only [benchmark]])
(:require [clojure.walk :as walk])) (:require [clojure.walk :as walk]))

View file

@ -1,91 +0,0 @@
(ns com.rpl.specter.transient
#+cljs
(:require-macros [com.rpl.specter.macros
:refer
[defnav
defpathedfn]])
(:use #+clj
[com.rpl.specter.macros :only
[defnav
defpathedfn]])
(:require [com.rpl.specter.impl :as i]
[com.rpl.specter :refer [subselect selected?]]))
(defnav
^{:doc "Navigates to the specified key of a transient collection,
navigating to nil if it doesn't exist."}
keypath!
[key]
(select* [this structure next-fn]
(next-fn (get structure key)))
(transform* [this structure next-fn]
(assoc! structure key (next-fn (get structure key)))))
(def END!
"Navigates to an empty (persistent) vector at the end of a transient vector."
(i/comp-paths* (i/->TransientEndNavigator)))
(defn- t-get-first
[tv]
(nth tv 0))
(defn- t-get-last
[tv]
(nth tv (dec (i/transient-vec-count tv))))
(defn- t-update-first
[tv next-fn]
(assoc! tv 0 (next-fn (nth tv 0))))
(defn- t-update-last
[tv next-fn]
(let [i (dec (i/transient-vec-count tv))]
(assoc! tv i (next-fn (nth tv i)))))
(def FIRST!
"Navigates to the first element of a transient vector."
(i/->PosNavigator t-get-first t-update-first))
(def LAST!
"Navigates to the last element of a transient vector."
(i/->PosNavigator t-get-last t-update-last))
#+clj
(defn- select-keys-from-transient-map
"Selects keys from transient map, because built-in select-keys uses
`find` which is unsupported."
[m m-keys]
(loop [result {}
m-keys m-keys]
(if-not (seq m-keys)
result
(let [k (first m-keys)
;; support Clojure 1.6 where contains? is broken on transients
item (get m k ::not-found)]
(recur (if-not (identical? item ::not-found)
(assoc result k item)
result)
(rest m-keys))))))
#+cljs
(defn- select-keys-from-transient-map
"Uses select-keys on a transient map."
[m m-keys]
(select-keys m m-keys))
(defnav
^{:doc "Navigates to the specified persistent submap of a transient map."}
submap!
[m-keys]
(select* [this structure next-fn]
(next-fn (select-keys-from-transient-map structure m-keys)))
(transform* [this structure next-fn]
(let [selected (select-keys-from-transient-map structure m-keys)
res (next-fn selected)]
(as-> structure %
(reduce (fn [m k]
(dissoc! m k))
% m-keys)
(reduce-kv (fn [m k v]
(assoc! m k v))
% res)))))

View file

@ -27,7 +27,7 @@
#+cljs [cljs.test.check.generators :as gen] #+cljs [cljs.test.check.generators :as gen]
#+cljs [cljs.test.check.properties :as prop :include-macros true] #+cljs [cljs.test.check.properties :as prop :include-macros true]
[com.rpl.specter :as s] [com.rpl.specter :as s]
[com.rpl.specter.transient :as t] [com.rpl.specter.transients :as t]
[clojure.set :as set])) [clojure.set :as set]))
;;TODO: ;;TODO: