diff --git a/API.md b/API.md index ee0959d..cfc77ae 100644 --- a/API.md +++ b/API.md @@ -71,7 +71,7 @@ - [`strip-ext`](#babashka.fs/strip-ext) - Strips extension via split-ext. - [`sym-link?`](#babashka.fs/sym-link?) - Determines if f is a symbolic link via java.nio.file.Files/isSymbolicLink. - [`temp-dir`](#babashka.fs/temp-dir) - Returns java.io.tmpdir property as path. - - [`unixy`](#babashka.fs/unixy) - Returns path as string with Unix-style file separators (/). + - [`unixify`](#babashka.fs/unixify) - Returns path as string with Unix-style file separators (/). - [`unzip`](#babashka.fs/unzip) - Unzips zip-file to dest directory (default "."). - [`update-file`](#babashka.fs/update-file) - Updates the contents of text file path using f applied to old contents and xs. - [`walk-file-tree`](#babashka.fs/walk-file-tree) - Walks f using Files/walkFileTree. @@ -889,16 +889,15 @@ Determines if `f` is a symbolic link via `java.nio.file.Files/isSymbolicLink`. Returns `java.io.tmpdir` property as path. -## `unixy` [:page_facing_up:](https://github.com/babashka/fs/blob/master/src/babashka/fs.cljc#L1122-L1128) - +## `unixify` [:page_facing_up:](https://github.com/babashka/fs/blob/master/src/babashka/fs.cljc#L1122-L1127) + ``` clojure -(unixy f) +(unixify f) ``` -Returns path as string with Unix-style file separators (`/`). Returns - argument unchanged on non-Windows systems. +Returns path as string with Unix-style file separators (`/`). ## `unzip` [:page_facing_up:](https://github.com/babashka/fs/blob/master/src/babashka/fs.cljc#L899-L926) diff --git a/CHANGELOG.md b/CHANGELOG.md index ec7c868..ec6392e 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -4,7 +4,7 @@ For a list of breaking changes, check [here](#breaking-changes). Babashka [fs](https://github.com/babashka/fs): file system utility library for Clojure -## v0.2.13 (2023-01-16) +## v0.2.14 (2023-01-16) - [#81](https://github.com/babashka/fs/issues/81): do not process directories in `strip-ext` and `split-ext` - Correct documentation for match/glob functions return value [@thenonameguy](https://github.com/thenonameguy) diff --git a/project.clj b/project.clj index 1a31b2a..1d68668 100644 --- a/project.clj +++ b/project.clj @@ -1,4 +1,4 @@ -(defproject babashka/fs "0.2.13" +(defproject babashka/fs "0.2.14" :description "Babashka file system utilities." :url "https://github.com/babashka/fs" :scm {:name "git" diff --git a/src/babashka/fs.cljc b/src/babashka/fs.cljc index ae1ceef..0f04184 100644 --- a/src/babashka/fs.cljc +++ b/src/babashka/fs.cljc @@ -1119,10 +1119,9 @@ (apply spit file new-val opts) new-val))) -(defn unixy - "Returns path as string with Unix-style file separators (`/`). Returns - argument unchanged on non-Windows systems." +(defn unixify + "Returns path as string with Unix-style file separators (`/`)." [f] (if win? (-> f as-path .toUri .getPath) - f)) + (str f))) diff --git a/test/babashka/fs_test.clj b/test/babashka/fs_test.clj index e23ef90..2f1633d 100644 --- a/test/babashka/fs_test.clj +++ b/test/babashka/fs_test.clj @@ -599,3 +599,8 @@ (let [file (fs/file (fs/temp-dir) (str (gensym)))] (spit file ", ") (is (= "foo, bar, baz" (fs/update-file file str/join ["foo" "bar" "baz"]))))) + +(deftest unixify-test + (when windows? + (is (str/includes? (fs/unixify (fs/normalize "README.md")) "/")) + (is (not (str/includes? (fs/unixify (fs/normalize "README.md")) fs/file-separator)))))