Created
September 27, 2017 23:38
-
-
Save markhepburn/a06dd189653b2faa93f9e1642fd64abf to your computer and use it in GitHub Desktop.
Patch cljs compiler for emacs-on-windows
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
;; The cljs compiler currently uses string-matching for path comparison; on windows (case-insensitive) | |
;; for some reason I have both C:\... and c:\... present, which fails. This is my monkey-patch. | |
;; See https://dev.clojure.org/jira/browse/CLJS-2221 | |
(in-ns 'cljs.util) | |
(require '[clojure.java.io :as io] | |
'[clojure.string :as string]) | |
(import '[java.net URLDecoder]) | |
(defn ^String relative-name | |
"Given a file return a path relative to the working directory. Given a | |
URL return the JAR relative path of the resource." | |
[x] | |
{:pre [(or (file? x) (url? x))]} | |
(letfn [(strip-user-dir [s] | |
(let [base-count (.getNameCount (.toPath (io/file (System/getProperty "user.dir")))) | |
file-path (.toPath (io/file s))] | |
(str (.subpath file-path base-count (.getNameCount file-path)))))] | |
(if (file? x) | |
(strip-user-dir (.getAbsolutePath x)) | |
(let [f (URLDecoder/decode (.getFile x))] | |
(if (string/includes? f ".jar!/") | |
(last (string/split f #"\.jar!/")) | |
(strip-user-dir f)))))) | |
(ns figwheel | |
(:require [figwheel-sidecar.repl-api :refer [start-figwheel! cljs-repl reset-autobuild]])) | |
;;; reset-autobuild included so it's accessible when we :cljs/quit back to the clj repl | |
(start-figwheel! "dev") | |
(cljs-repl) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment