File system utilities for babashka. This library isn't part of babashka itself yet, but will be. Also can be used from the JVM.
Working towards an initial release. The API might still change. Awaiting user feedback.
Babashka is a scripting utility. It's convenient to have cross platform file
system utilities available for scripting. The namespace clojure.java.io
already offers a bunch of useful features, but isn't up to date with java.nio
.
The main inspiration for this library is
clj-commons/fs but some of its functions
can be optimized by leveraging java.nio
and others might need revision. We do
not guarantee any compatibility with the clj-commons
library.
API docs are available at babashka.org/fs. Most
functions take a string, java.io.File
or java.nio.file.Path
as input and
return a java.nio.file.Path
. Coercion into a File
or Path
can be done
using fs/file
and fs/path
.
Until this library is included in babashka, you can use this library as a git lib:
#!/usr/bin/env bb
(require '[babashka.deps :as deps])
(deps/add-deps '{:deps {babashka/fs
{:git/url "https://github.com/babashka/fs"
:sha "b008b2d6ea64e49bf76066b7f057ae4638534e35"}}})
or use any later SHA.
On the JVM, add it to deps.edn
.
(require '[babashka.fs :as fs])
The glob
function takes a root path and a pattern. The pattern is interpreted
as documented
here.
(map str (fs/glob "." "**{.clj,cljc}"))
Output:
("project.clj" "test/babashka/fs_test.clj" "src/babashka/fs.cljc")
$ clojure -M:test
Static files including compiled JS are hosted on Github. This is set up like described here:
All the commands below assume that you already have a git project initialized and that you are in its root folder.
# Create an orphan branch named gh-pages
git checkout --orphan gh-pages
# Remove all files from staging
git rm -rf .
# Create an empty commit so that you will be able to push on the branch next
git commit --allow-empty -m "Init empty branch"
# Push the branch
git push origin gh-pages
Now that the branch is created and pushed to origin, let’s configure the worktree correctly:
# Come back to master
git checkout master
# Add gh-pages to .gitignore
echo "gh-pages/" >> .gitignore
git worktree add gh-pages gh-pages
After cloning this repo to a new dir:
git fetch origin gh-pages
git worktree add gh-pages gh-pages
To deploy to Github Pages:
script/release
Copyright © 2020-2021 Michiel Borkent
Distributed under the EPL License, same as Clojure. See LICENSE.
Can you improve this documentation?Edit on GitHub
cljdoc is a website building & hosting documentation for Clojure/Script libraries
× close