Subject: [PATCH] build: minify-build-system: Fail to install empty files.

From: Efraim Flashner <[email-masked]>
Date: Wed, 6 May 2020 11:39:23 +0300

* guix/build/minify-build-system.scm (install): Produce an error if the
minified file is zero bytes.
---

I'm pretty sure this can go directly into master. 'guix refresh -l
uglify-js' shows 93 packages. 'guix refresh -l r-shiny' shows 71
packages. The 4 differing packages are hpcguix-web, calibre, mate and
snap.

My only real concern is that r-shiny is calling minify directly and so
we might want it to error during the 'build phase and not during the
'install phase.

---
 guix/build/minify-build-system.scm | 9 +++++++--
 1 file changed, 7 insertions(+), 2 deletions(-)

diff --git a/guix/build/minify-build-system.scm b/guix/build/minify-build-system.scm
index 563def88e9..92158a033f 100644
--- a/guix/build/minify-build-system.scm
+++ b/guix/build/minify-build-system.scm
@@ -1,5 +1,6 @@
 ;;; GNU Guix --- Functional package management for GNU
 ;;; Copyright © 2016 Ricardo Wurmus <[email-masked]>
+;;; Copyright © 2020 Efraim Flashner <[email-masked]>
 ;;;
 ;;; This file is part of GNU Guix.
 ;;;
@@ -54,8 +55,12 @@
   (let* ((out (assoc-ref outputs "out"))
          (js  (string-append out "/share/javascript/")))
     (mkdir-p js)
-    (for-each (cut install-file <> js)
-              (find-files "guix/build" "\\.min\\.js$")))
+    (for-each
+      (lambda (file)
+        (if (not (zero? (stat:size (stat file))))
+          (install-file file js)
+          (error "File is empty: " file)))
+      (find-files "guix/build" "\\.min\\.js$")))
   #t)
 
 (define %standard-phases
-- 
2.26.2