diff --git a/sci b/sci index a7f8d05f..17f03e8f 160000 --- a/sci +++ b/sci @@ -1 +1 @@ -Subproject commit a7f8d05f08ab150621c2403dacdd57c47ea09ff4 +Subproject commit 17f03e8f73b08fbf30d870ceb23be0d7945f1d58 diff --git a/src/babashka/impl/classes.clj b/src/babashka/impl/classes.clj index 81714475..cfbc2e2f 100644 --- a/src/babashka/impl/classes.clj +++ b/src/babashka/impl/classes.clj @@ -149,7 +149,9 @@ java.nio.file.FileAlreadyExistsException java.nio.file.FileSystem java.nio.file.FileSystems + java.nio.file.FileVisitor java.nio.file.FileVisitOption + java.nio.file.FileVisitResult java.nio.file.Files java.nio.file.LinkOption java.nio.file.NoSuchFileException diff --git a/src/babashka/main.clj b/src/babashka/main.clj index d1713057..291fe491 100644 --- a/src/babashka/main.clj +++ b/src/babashka/main.clj @@ -434,6 +434,17 @@ If neither -e, -f, or --socket-repl are specified, then the first argument that Thread java.lang.Thread Throwable java.lang.Throwable}) +(def reify-opts + {'java.nio.file.FileVisitor + (fn [{:keys [:methods]}] + {:object (reify java.nio.file.FileVisitor + (preVisitDirectory [this p attrs] + ((get methods 'preVisitDirectory) this p attrs)) + (postVisitDirectory [this p attrs] + ((get methods 'postVisitDirectory) this p attrs)) + (visitFile [this p attrs] + ((get methods 'visitFile) this p attrs)))})}) + (def input-var (sci/new-dynamic-var '*input* nil)) (def edn-readers (cond-> {} features/yaml? @@ -500,7 +511,7 @@ If neither -e, -f, or --socket-repl are specified, then the first argument that (add-classpath* jar)) load-fn (fn [{:keys [:namespace :reload]}] (when-let [{:keys [:loader]} - @cp-state] + @cp-state] (if ;; ignore built-in namespaces when uberscripting, unless with :reload (and uberscript (not reload) @@ -546,7 +557,8 @@ If neither -e, -f, or --socket-repl are specified, then the first argument that :imports imports :load-fn load-fn :uberscript uberscript - :readers core/data-readers} + :readers core/data-readers + :reify reify-opts} opts (addons/future opts) sci-ctx (sci/init opts) _ (vreset! common/ctx sci-ctx) @@ -558,9 +570,9 @@ If neither -e, -f, or --socket-repl are specified, then the first argument that file (try [[(read-file file)] nil] (catch Exception e (error-handler e {:expression expressions - :verbose? verbose? - :preloads preloads - :loader (:loader @cp-state)})))) + :verbose? verbose? + :preloads preloads + :loader (:loader @cp-state)})))) expression (str/join " " expressions) ;; this might mess with the locations... exit-code ;; handle preloads @@ -571,9 +583,9 @@ If neither -e, -f, or --socket-repl are specified, then the first argument that (sci/eval-string* sci-ctx preloads) (catch Throwable e (error-handler e {:expression expression - :verbose? verbose? - :preloads preloads - :loader (:loader @cp-state)}))))) + :verbose? verbose? + :preloads preloads + :loader (:loader @cp-state)}))))) nil)) exit-code (or exit-code @@ -613,9 +625,9 @@ If neither -e, -f, or --socket-repl are specified, then the first argument that res))))) (catch Throwable e (error-handler e {:expression expression - :verbose? verbose? - :preloads preloads - :loader (:loader @cp-state)})))) + :verbose? verbose? + :preloads preloads + :loader (:loader @cp-state)})))) uberscript [nil 0] :else [(repl/start-repl! sci-ctx) 0])) 1)]