Skip to content

Commit

Permalink
CLJS-2152: "is not a relative path" exception thrown when :libs dir…
Browse files Browse the repository at this point in the history
…ectory is provided.
  • Loading branch information
anmonteiro authored and swannodette committed Jul 8, 2017
1 parent a9cb508 commit df13513
Show file tree
Hide file tree
Showing 5 changed files with 39 additions and 1 deletion.
2 changes: 1 addition & 1 deletion src/main/clojure/cljs/closure.clj
Original file line number Diff line number Diff line change
Expand Up @@ -1571,7 +1571,7 @@
(if (.endsWith lib-path ".js")
(util/get-name url)
(let [path (util/path url)]
(subs path (+ (.lastIndexOf path lib-path) (.length lib-path)))))))
(subs path (+ (inc (.lastIndexOf path lib-path)) (.length lib-path)))))))

(defn ^String rel-output-path
"Given a IJavaScript which points to a .js file either in memory, in a jar file,
Expand Down
5 changes: 5 additions & 0 deletions src/test/cljs/js_libs/tabby.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
goog.provide("tabby");

tabby.hello = function() {
return "hello there from tabby";
};
6 changes: 6 additions & 0 deletions src/test/cljs_build/libs_test/core.cljs
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
(ns libs-test.core
(:require [tabby]))

(enable-console-print!)

(println (tabby/hello))
17 changes: 17 additions & 0 deletions src/test/clojure/cljs/build_api_tests.clj
Original file line number Diff line number Diff line change
Expand Up @@ -253,3 +253,20 @@
opts cenv)
(is (.exists (io/file out "preloads_test/preload.cljs")))
(is (contains? (get-in @cenv [::ana/namespaces 'preloads-test.preload :defs]) 'preload-var))))

(deftest test-libs-cljs-2152
(let [out (.getPath (io/file (test/tmp-dir) "libs-test-out"))
{:keys [inputs opts]} {:inputs (str (io/file "src" "test" "cljs_build"))
:opts {:main 'libs-test.core
:output-dir out
:libs ["src/test/cljs/js_libs"]
:optimizations :none
:closure-warnings {:check-types :off}}}
cenv (env/default-compiler-env)]
(test/delete-out-files out)
(build/build (build/inputs
(io/file "src/test/cljs_build/libs_test/core.cljs") (io/file "src/test/cljs/js_libs")
(io/file inputs "libs_test/core.cljs")
(io/file "src/test/cljs/js_libs"))
opts cenv)
(is (.exists (io/file out "tabby.js")))))
10 changes: 10 additions & 0 deletions src/test/clojure/cljs/closure_tests.clj
Original file line number Diff line number Diff line change
Expand Up @@ -73,3 +73,13 @@

(deftest test-string-provides
(is (= ["CB0BFFB"] (deps/-provides "var x = 42;"))))

(deftest test-lib-rel-path-cljs-2152
(let [ijs {:provides ["tabby"]
:url (io/as-url (io/file "src/test/cljs/js_libs/tabby.js"))
:lib-path "src/test/cljs/js_libs"}]
(is (= (closure/lib-rel-path ijs) "tabby.js")))
(let [ijs {:provides ["tabby"]
:url (io/as-url (io/file "src/test/cljs/js_libs/tabby.js"))
:lib-path (.getAbsolutePath (io/file "src/test/cljs/js_libs/tabby.js"))}]
(is (= (closure/lib-rel-path ijs) "tabby.js"))))

0 comments on commit df13513

Please sign in to comment.