about summary refs log tree commit diff
diff options
context:
space:
mode:
authorArun Isaac2025-04-22 21:57:52 +0100
committerArun Isaac2025-04-22 22:19:32 +0100
commitff89b8cef7b56d3665937de02629e60c8ca1bed7 (patch)
tree3023fce3280861b85e0af05b06f4f5f9cc1c250c
parent2e530c957eea0b400c959a91885f2616e01b2568 (diff)
downloadravanan-ff89b8cef7b56d3665937de02629e60c8ca1bed7.tar.gz
ravanan-ff89b8cef7b56d3665937de02629e60c8ca1bed7.tar.lz
ravanan-ff89b8cef7b56d3665937de02629e60c8ca1bed7.zip
work/command-line-tool: Canonicalize secondary files too.
* ravanan/work/command-line-tool.scm (canonicalize-file-value):
Canonicalize secondary files too.
-rw-r--r--ravanan/work/command-line-tool.scm25
1 files changed, 16 insertions, 9 deletions
diff --git a/ravanan/work/command-line-tool.scm b/ravanan/work/command-line-tool.scm
index 857987e..198addd 100644
--- a/ravanan/work/command-line-tool.scm
+++ b/ravanan/work/command-line-tool.scm
@@ -27,8 +27,10 @@
   #:use-module (gcrypt base16)
   #:use-module (gcrypt hash)
   #:use-module (json)
+  #:use-module (ravanan work monads)
   #:use-module (ravanan work types)
   #:use-module (ravanan work utils)
+  #:use-module (ravanan work vectors)
   #:export (value->string
             call-with-current-directory
             object-type
@@ -225,15 +227,20 @@ actually paths."
         (location (or (assoc-ref value "location")
                       (string-append "file://" (assoc-ref value "path")))))
     ;; Populate all fields of the File type value.
-    `(("class" . "File")
-      ("location" . ,location)
-      ("path" . ,path)
-      ("basename" . ,(basename path))
-      ("nameroot" . ,(file-name-stem path))
-      ("nameext" . ,(file-name-extension path))
-      ("size" . ,(stat:size (stat path)))
-      ("checksum" . ,(or (assoc-ref value "checksum")
-                         (checksum path))))))
+    (maybe-assoc-set `(("class" . "File")
+                       ("location" . ,location)
+                       ("path" . ,path)
+                       ("basename" . ,(basename path))
+                       ("nameroot" . ,(file-name-stem path))
+                       ("nameext" . ,(file-name-extension path))
+                       ("size" . ,(stat:size (stat path)))
+                       ("checksum" . ,(or (assoc-ref value "checksum")
+                                          (checksum path))))
+      (cons "secondaryFiles"
+            (maybe-let* ((secondary-files
+                          (maybe-assoc-ref (just value) "secondaryFiles")))
+              (just (vector-map canonicalize-file-value
+                                secondary-files)))))))
 
 (define* (evaluate-javascript node expression #:optional (preamble ""))
   "Evaluate javascript @var{expression} using @var{node}. Evaluate