-
-
Save tomjack/0f01eed063bdfacb9c9d to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
(defn is-file-line [line] | |
(cond (>= (.indexOf line "Added:") 0) true | |
(>= (.indexOf line "Modified:") 0) true | |
:else false)) | |
(defn is-jsfile-line [line] | |
(and (is-file-line line) (.endsWith line ".js"))) | |
(def debugger-line #"(?<!//.{0,102400})debugger") | |
(def alert-line #"(?<!//.{0,102400})alert\s*\(") | |
(def console-line #"(?<!//.{0,102400})console") | |
(defn process-js [line] | |
(def lower-line (.substring (.toLowerCase line) 1)) | |
(cond (re-find debugger-line lower-line) true | |
(re-find alert-line lower-line) true | |
(re-find console-line lower-line) true | |
:else false)) | |
(def added-line #"^\+[^\+]") | |
(defn get-lines [lines state] | |
(when-let [[line & reader] (seq lines)] | |
(if (is-jsfile-line line) | |
(lazy-seq (get-lines reader "js"))) | |
(if (and (= state "js") | |
(not (is-file-line line))) | |
(if (and (re-find added-line line) (process-js line)) | |
(cons line | |
(lazy-seq (get-lines reader "js"))) | |
(lazy-seq (get-lines reader "js"))) | |
(lazy-seq (get-lines reader "not-js"))))) | |
(doseq [line (get-lines (line-seq (java.io.BufferedReader. *in*)) "not-js")] | |
(println line)) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment