Giter Site home page Giter Site logo

codesmith-gmbh / fs Goto Github PK

View Code? Open in Web Editor NEW

This project forked from babashka/fs

0.0 0.0 0.0 382 KB

File system utility library

Home Page: https://babashka.org/fs

License: Eclipse Public License 1.0

Clojure 58.60% Shell 0.09% HTML 32.08% CSS 6.63% JavaScript 2.60%

fs's Introduction

babashka.fs

Clojars Project bb built-in

File system utilities. This library can be used on the JVM and is also included in babashka (>= 0.2.9).

Why

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 it predates java.nio. The nio package isn't that nice to use from Clojure and this library should help with that.

The main inspirations for this library are clojure.java.io, clj-commons/fs and corasaurus-hex/fs.

API docs

See API.md.

Usage

(require '[babashka.fs :as fs])
(fs/directory? ".") ;;=> true

Examples

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")

The function exec-paths returns all entries from PATH as Paths. To search all these directories for an executable, e.g. java, you can combine it with list-dirs which searches files directly in the directories using an (optional) glob pattern:

(str (first (filter fs/executable? (fs/list-dirs (filter fs/exists? (fs/exec-paths)) "java"))))
"/Users/borkdude/.jenv/versions/11.0/bin/java"

For convenience, the above use case is also supported using the which function:

(str (fs/which "java"))
"/Users/borkdude/.jenv/versions/11.0/bin/java"

Test

$ bb test

License

Copyright © 2020-2021 Michiel Borkent

Distributed under the EPL License, same as Clojure. See LICENSE.

fs's People

Contributors

borkdude avatar lread avatar eval avatar eamonnsullivan avatar duzunov avatar corasaurus-hex avatar tekacs avatar benjamin-asdf avatar bobisageek avatar retrogradeorbit avatar hugoduncan avatar holyjak avatar jjttjj avatar kiramclean avatar kineolyan avatar pavlosmelissinos avatar sohalt avatar thenonameguy avatar ikappaki avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.