summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorNicolas Graves <ngraves@ngraves.fr>2025-09-10 23:46:04 +0200
committerJelle Licht <jlicht@fsfe.org>2025-10-13 10:26:30 +0200
commit287a767b87cf150d9d2ed2a704b434c7e7d39d6b (patch)
tree366dafd37e142fdd056cee5c56f5746aa3995045
parente86542b156f7982bae8b98b6b4926d4d0f011b41 (diff)
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 <jlicht@fsfe.org>
-rw-r--r--guix/build/node-build-system.scm20
1 files 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 <philip@philipmcgrath.com>
;;; Copyright © 2022 Liliana Marie Prikler <liliana.prikler@gmail.com>
;;; Copyright © 2024 Daniel Khodabakhsh <d.khodabakhsh@gmail.com>
+;;; Copyright © 2025 Nicolas Graves <ngraves@ngraves.fr>
;;;
;;; 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