This page is not created by, affiliated with, or supported by Slack Technologies, Inc.
Is there a way to get the path to the directory where the script was launched (or the project)? So that command will get the path of the project's folder no matter where it is
✅ 2
Ex: Script is at /home/dir/project/script.clj I launch it from cmd while i'm in /home/dir and return /home/dir/project/. I call it from /tmp and I get /home/dir/project/
You can do this by using *file*
:
(ns script)
(require '[babashka.fs :as fs])
(def script-file *file*)
(def script-dir (str (fs/parent script-file)))
you must execute this on the top level like in the above example, it does not work in function bodies, since *file*
isn't bound anymore
✅ 2
Thanks!