Back
absolutize (clj)
(source)function
(absolutize f)
Converts f into an absolute path via Path#toAbsolutePath.
Examples
clj-kondo/clj-kondo
(ns clj-kondo.impl.copied-config-test
(:require [babashka.fs :as fs]
[clj-kondo.impl.core :as core-impl]
[clj-kondo.impl.utils :as utils]
[clojure.string :as str]
[clojure.test :refer [deftest is testing]]))
(deftest copied-configs-resolution-test
(testing "no findings"
(testing "when clj-kondo :config-dir is not present"
(is (nil? (core-impl/copied-config-paths {:detected-configs (atom ["cfg1" "cfg2"])}))))
(testing "when no configs are copied"
(is (nil? (core-impl/copied-config-paths {:config-dir "cfg-dir"
:detected-configs (atom [])})))))
(testing "found copied configs"
(testing "are sorted"
(is (= ["cfg-dir/cfg/b"
"cfg-dir/cfg/c"
"cfg-dir/cfg/w"
"cfg-dir/cfg/z"]
(core-impl/copied-config-paths {:config-dir "cfg-dir"
:detected-configs (atom ["cfg/c" "cfg/z" "cfg/b" "cfg/w"])}))))
(testing "returns config-dir relative to current dir"
(is (= ["cfg-dir/cfg1"]
(core-impl/copied-config-paths {:config-dir (str (fs/absolutize "cfg-dir"))
:detected-configs (atom ["cfg1"])}))))
(when utils/windows?
(testing "unixifies all paths on Windows"
(is (= ["cfg-dir/cfg/b" "cfg-dir/cfg/c" "cfg-dir/cfg/w" "cfg-dir/cfg/z"]
(core-impl/copied-config-paths {:config-dir (str (fs/absolutize "cfg-dir"))
:detected-configs (atom ["cfg\\c" "cfg\\z" "cfg\\b" "cfg\\w"])})))))))
scarletcomply/license-finder
(ns scarlet.license-finder.deps
(:require [babashka.fs :as fs]
[scarlet.license-finder.deps.lein :as lein]
[scarlet.license-finder.deps.npm :as npm]
[scarlet.license-finder.deps.shadow-cljs :as shadow-cljs]
[scarlet.license-finder.deps.tools-deps :as tools-deps]))
(defmethod find-dependencies "shadow-cljs.edn"
[file-path opts]
(let [path (fs/absolutize file-path)
package-json-path (fs/path (fs/parent path) "package.json")]
(cond-> (shadow-cljs/find-dependencies file-path opts)
(fs/exists? package-json-path) (concat (npm/find-dependencies package-json-path opts)))))