import: npm-binary: Handle vector of licenses.

* guix/import/npm-binary.scm (<package-revision>)[license]: Handle the
case where a vector of licenses is used.

* tests/npm-binary.scm (foo-json): Redefine as a procedure with
license keyword.
  (test-source-hash): Redefine with direct reference to test-source.
  (foo-sexp): Redefine as a procedure with license keyword.
  (npm-binary->guix-package test): Use foo-json and foo-sexp.
  (npm-binary->guix-package with multiple licenses): Add test.

Change-Id: I9d6adb2ae2820678260fed1a67e91e22feb448b8
Signed-off-by: Jelle Licht <jlicht@fsfe.org>
This commit is contained in:
Nicolas Graves via Guix-patches via 2025-03-24 08:29:16 +01:00 committed by Andreas Enge
parent 8aca24f41e
commit d3086f85e0
No known key found for this signature in database
GPG key ID: F7D5C9BF765C61E3
2 changed files with 102 additions and 72 deletions

View file

@ -105,7 +105,17 @@
(match (assoc "type" alist)
((_ . (? string? type))
(spdx-string->license type))
(_ #f)))))
(_ #f)))
((? vector? vector)
(match (filter-map
(match-lambda
((? string? str) (spdx-string->license str))
(_ #f))
(vector->list vector))
((license rest ...)
(cons* license rest))
((license)
license)))))
(description package-revision-description ;string
"description" empty-or-string)
(dist package-revision-dist "dist" json->dist)) ;dist
@ -250,7 +260,9 @@
(home-page ,home-page)
(synopsis ,synopsis)
(description ,description)
(license ,license))
(license ,(if (list? license)
`(list ,@license)
license)))
(map (match-lambda (($ <package-revision> name version)
(list name (semver->string version))))
resolved-deps))))