build-system/minify: Phases no longer return a Boolean.

* guix/build/minify-build-system.scm (minify): Use 'for-each' instead of
'every'.  Call 'close-pipe' and call error when it returns non-zero.
(build): Use 'for-each' instead of 'every'.
(install): Remove trailing #t.
This commit is contained in:
Ludovic Courtès 2020-11-24 23:14:30 +01:00
parent 112982526f
commit 49eadd270c
No known key found for this signature in database
GPG key ID: 090B11993D9AEBB5

View file

@ -23,6 +23,7 @@ (define-module (guix build minify-build-system)
#:use-module (guix build utils) #:use-module (guix build utils)
#:use-module (srfi srfi-1) #:use-module (srfi srfi-1)
#:use-module (srfi srfi-26) #:use-module (srfi srfi-26)
#:use-module (ice-9 match)
#:use-module (ice-9 popen) #:use-module (ice-9 popen)
#:export (%standard-phases #:export (%standard-phases
minify-build minify-build
@ -42,14 +43,17 @@ (define* (minify file #:key target (directory ""))
(minified (open-pipe* OPEN_READ "uglify-js" file))) (minified (open-pipe* OPEN_READ "uglify-js" file)))
(call-with-output-file installed (call-with-output-file installed
(cut dump-port minified <>)) (cut dump-port minified <>))
#t)) (match (close-pipe minified)
(0 #t)
(status
(error "uglify-js failed" status)))))
(define* (build #:key javascript-files (define* (build #:key javascript-files
#:allow-other-keys) #:allow-other-keys)
(let ((files (or javascript-files (let ((files (or javascript-files
(find-files "src" "\\.js$")))) (find-files "src" "\\.js$"))))
(mkdir-p "guix/build") (mkdir-p "guix/build")
(every (cut minify <> #:directory "guix/build/") files))) (for-each (cut minify <> #:directory "guix/build/") files)))
(define* (install #:key outputs #:allow-other-keys) (define* (install #:key outputs #:allow-other-keys)
(let* ((out (assoc-ref outputs "out")) (let* ((out (assoc-ref outputs "out"))
@ -60,8 +64,7 @@ (define* (install #:key outputs #:allow-other-keys)
(if (not (zero? (stat:size (stat file)))) (if (not (zero? (stat:size (stat file))))
(install-file file js) (install-file file js)
(error "File is empty: " file))) (error "File is empty: " file)))
(find-files "guix/build" "\\.min\\.js$"))) (find-files "guix/build" "\\.min\\.js$"))))
#t)
(define %standard-phases (define %standard-phases
(modify-phases gnu:%standard-phases (modify-phases gnu:%standard-phases