summaryrefslogtreecommitdiff
path: root/guix/build/node-build-system.scm
diff options
context:
space:
mode:
authorJulien Lepiller <julien@lepiller.eu>2019-07-14 14:50:21 +0200
committerJulien Lepiller <julien@lepiller.eu>2019-07-14 14:57:46 +0200
commit8eb0ba532ebbebef23180e666e0607ea735f9c1a (patch)
treeba31760fdf7777274dae2e6b63b3c6ec05ab90ee /guix/build/node-build-system.scm
parent09a1f92f61d1ab11d2cf9f7a0983f4fc9f436f57 (diff)
guix: node-build-system: Use guile-json instead of a custom parser.
* guix/build/json.scm: Remove file. * Makefile.am: Remove it. * guix/build/node-build-system.scm: Use (json parser) instead of (guix build json). * guix/build-system/node.scm: Idem.
Diffstat (limited to 'guix/build/node-build-system.scm')
-rw-r--r--guix/build/node-build-system.scm28
1 files changed, 15 insertions, 13 deletions
diff --git a/guix/build/node-build-system.scm b/guix/build/node-build-system.scm
index 3c0ac2a12b..231e60488a 100644
--- a/guix/build/node-build-system.scm
+++ b/guix/build/node-build-system.scm
@@ -19,12 +19,12 @@
(define-module (guix build node-build-system)
#:use-module ((guix build gnu-build-system) #:prefix gnu:)
- #:use-module (guix build json)
#:use-module (guix build union)
#:use-module (guix build utils)
#:use-module (ice-9 match)
#:use-module (ice-9 popen)
#:use-module (ice-9 regex)
+ #:use-module (json parser)
#:use-module (srfi srfi-1)
#:use-module (srfi srfi-26)
#:export (%standard-phases
@@ -39,12 +39,12 @@
(define* (read-package-data #:key (filename "package.json"))
(call-with-input-file filename
(lambda (port)
- (read-json port))))
+ (json->scm port))))
(define* (build #:key inputs #:allow-other-keys)
(define (build-from-package-json? package-file)
(let* ((package-data (read-package-data #:filename package-file))
- (scripts (assoc-ref package-data "scripts")))
+ (scripts (hash-ref package-data "scripts")))
(assoc-ref scripts "build")))
"Build a new node module using the appropriate build system."
;; XXX: Develop a more robust heuristic, allow override
@@ -103,13 +103,15 @@ the @file{bin} directory."
(target (string-append out "/lib"))
(binaries (string-append out "/bin"))
(data (read-package-data))
- (modulename (assoc-ref data "name"))
- (binary-configuration (match (assoc-ref data "bin")
- (('@ configuration ...) configuration)
- ((? string? configuration) configuration)
- (#f #f)))
- (dependencies (match (assoc-ref data "dependencies")
- (('@ deps ...) deps)
+ (modulename (hash-ref data "name"))
+ (binary-configuration (match (hash-ref data "bin")
+ ((? hash-table? hash-table)
+ (hash-map->list cons hash-table))
+ ((? string? configuration) configuration)
+ (#f #f)))
+ (dependencies (match (hash-ref data "dependencies")
+ ((? hash-table? hash-table)
+ (hash-map->list cons hash-table))
(#f #f))))
(mkdir-p target)
(copy-recursively "." (string-append target "/node_modules/" modulename))
@@ -121,7 +123,7 @@ the @file{bin} directory."
(begin
(mkdir-p binaries)
(symlink (string-append target "/node_modules/" modulename "/"
- binary-configuration)
+ binary-configuration)
(string-append binaries "/" modulename))))
((list? binary-configuration)
(for-each
@@ -131,12 +133,12 @@ the @file{bin} directory."
(begin
(mkdir-p (dirname (string-append binaries "/" key)))
(symlink (string-append target "/node_modules/" modulename "/"
- value)
+ value)
(string-append binaries "/" key))))))
binary-configuration))
(else
(symlink (string-append target "/node_modules/" modulename "/bin")
- binaries)))
+ binaries)))
(when dependencies
(mkdir-p
(string-append target "/node_modules/" modulename "/node_modules"))