Skip to content

Commit

Permalink
Add unixify test
Browse files Browse the repository at this point in the history
  • Loading branch information
borkdude committed Jan 16, 2023
1 parent f823ab0 commit 8a8bfa6
Show file tree
Hide file tree
Showing 5 changed files with 15 additions and 12 deletions.
11 changes: 5 additions & 6 deletions API.md
Original file line number Diff line number Diff line change
Expand Up @@ -71,7 +71,7 @@
- [`strip-ext`](#babashka.fs/strip-ext) - Strips extension via <code>split-ext</code>.
- [`sym-link?`](#babashka.fs/sym-link?) - Determines if <code>f</code> is a symbolic link via <code>java.nio.file.Files/isSymbolicLink</code>.
- [`temp-dir`](#babashka.fs/temp-dir) - Returns <code>java.io.tmpdir</code> property as path.
- [`unixy`](#babashka.fs/unixy) - Returns path as string with Unix-style file separators (<code>/</code>).
- [`unixify`](#babashka.fs/unixify) - Returns path as string with Unix-style file separators (<code>/</code>).
- [`unzip`](#babashka.fs/unzip) - Unzips <code>zip-file</code> to <code>dest</code> directory (default <code>"."</code>).
- [`update-file`](#babashka.fs/update-file) - Updates the contents of text file <code>path</code> using <code>f</code> applied to old contents and <code>xs</code>.
- [`walk-file-tree`](#babashka.fs/walk-file-tree) - Walks f using Files/walkFileTree.
Expand Down Expand Up @@ -889,16 +889,15 @@ Determines if `f` is a symbolic link via `java.nio.file.Files/isSymbolicLink`.

Returns `java.io.tmpdir` property as path.

## <a name="babashka.fs/unixy">`unixy`</a> [:page_facing_up:](https://github.com/babashka/fs/blob/master/src/babashka/fs.cljc#L1122-L1128)
<a name="babashka.fs/unixy"></a>
## <a name="babashka.fs/unixify">`unixify`</a> [:page_facing_up:](https://github.com/babashka/fs/blob/master/src/babashka/fs.cljc#L1122-L1127)
<a name="babashka.fs/unixify"></a>
``` 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 (`/`).

## <a name="babashka.fs/unzip">`unzip`</a> [:page_facing_up:](https://github.com/babashka/fs/blob/master/src/babashka/fs.cljc#L899-L926)
<a name="babashka.fs/unzip"></a>
Expand Down
2 changes: 1 addition & 1 deletion CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down
2 changes: 1 addition & 1 deletion project.clj
Original file line number Diff line number Diff line change
@@ -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"
Expand Down
7 changes: 3 additions & 4 deletions src/babashka/fs.cljc
Original file line number Diff line number Diff line change
Expand Up @@ -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)))
5 changes: 5 additions & 0 deletions test/babashka/fs_test.clj
Original file line number Diff line number Diff line change
Expand Up @@ -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)))))

0 comments on commit 8a8bfa6

Please sign in to comment.