guix_mirror_bot pushed a commit to branch javascript-team
in repository guix.

commit af0ab5bc95333e4e4419685ef641a04456d6471b
Author: Nicolas Graves <[email protected]>
AuthorDate: Wed Sep 10 23:46:04 2025 +0200

    build-system: node: Remove assoc-ref* helper.
    
    This procedure has little added value and is basically equivalent to a
    simple composition of assoc-ref and or.
    
    * guix/build/node-build-system.scm (assoc-ref*): Remove procedure.
    (patch-dependencies, build, avoid-node-gyp-rebuild): Replace use of
    assoc-ref*.
    
    Change-Id: I947a66fe91eaa2b4adc8dc405232a32257f9d061
    Signed-off-by: Jelle Licht <[email protected]>
---
 guix/build/node-build-system.scm | 20 ++++++++------------
 1 file changed, 8 insertions(+), 12 deletions(-)

diff --git a/guix/build/node-build-system.scm b/guix/build/node-build-system.scm
index 05940bc997..18c331ab18 100644
--- a/guix/build/node-build-system.scm
+++ b/guix/build/node-build-system.scm
@@ -5,6 +5,7 @@
 ;;; Copyright © 2021, 2022 Philip McGrath <[email protected]>
 ;;; Copyright © 2022 Liliana Marie Prikler <[email protected]>
 ;;; Copyright © 2024 Daniel Khodabakhsh <[email protected]>
+;;; Copyright © 2025 Nicolas Graves <[email protected]>
 ;;;
 ;;; This file is part of GNU Guix.
 ;;;
@@ -40,12 +41,6 @@
             replace-fields
             with-atomic-json-file-replacement))
 
-(define* (assoc-ref* alist key #:optional default)
-  "Like assoc-ref, but return DEFAULT instead of #f if no value exists."
-  (match (assoc key alist)
-    (#f default)
-    ((_ . value) value)))
-
 (define* (alist-pop alist key #:optional (= equal?))
   "Return two values, the first pair in ALIST with key KEY, and the other
 elements.  Equality calls are made as (= KEY ALISTCAR)."
@@ -291,8 +286,8 @@ only after the 'patch-dependencies' phase."
                 (fold
                   (lambda (dependency dependencies)
                     (assoc-set! dependencies (car dependency) (cdr 
dependency)))
-                  (assoc-ref* pkg-meta "peerDependencies" '())
-                  (assoc-ref* pkg-meta "dependencies" '())))))))))
+                  (or (assoc-ref pkg-meta "peerDependencies") '())
+                  (or (assoc-ref pkg-meta "dependencies") '())))))))))
   #t)
 
 (define* (delete-lockfiles #:key inputs #:allow-other-keys)
@@ -312,8 +307,9 @@ exist."
     #t))
 
 (define* (build #:key inputs #:allow-other-keys)
-  (let ((package-meta (call-with-input-file "package.json" json->scm)))
-    (if (assoc-ref* (assoc-ref* package-meta "scripts" '()) "build" #f)
+  (let* ((package-meta (call-with-input-file "package.json" json->scm))
+         (scripts (assoc-ref package-meta "scripts")))
+    (if (and scripts (assoc-ref scripts "build"))
         (let ((npm (string-append (assoc-ref inputs "node") "/bin/npm")))
           (invoke npm "run" "build"))
         (format #t "there is no build script to run~%"))
@@ -386,9 +382,9 @@ would try to run 'node-gyp rebuild'."
   (define pkg-meta
     (call-with-input-file installed-package.json json->scm))
   (define scripts
-    (assoc-ref* pkg-meta "scripts" '()))
+    (or (assoc-ref pkg-meta "scripts") '()))
 
-  (when (equal? "node-gyp rebuild" (assoc-ref* scripts "install" #f))
+  (when (equal? "node-gyp rebuild" (assoc-ref scripts "install"))
     (call-with-output-file installed-package.json
       (lambda (out)
         (scm->json

Reply via email to