unofficial mirror of guix-patches@gnu.org 
 help / color / mirror / code / Atom feed
From: Ricardo Wurmus <rekado@elephly.net>
To: 27132@debbugs.gnu.org
Cc: Ricardo Wurmus <rekado@elephly.net>
Subject: bug#27132: [PATCH 6/6] gnu: Add uglify-js.
Date: Mon, 29 May 2017 19:21:31 +0200	[thread overview]
Message-ID: <20170529172131.20954-6-rekado@elephly.net> (raw)
In-Reply-To: <20170529172131.20954-1-rekado@elephly.net>

* gnu/packages/lisp.scm (uglify-js): New variable.
---
 gnu/packages/lisp.scm | 47 +++++++++++++++++++++++++++++++++++++++++++++++
 1 file changed, 47 insertions(+)

diff --git a/gnu/packages/lisp.scm b/gnu/packages/lisp.scm
index 959d4c534..2980b7004 100644
--- a/gnu/packages/lisp.scm
+++ b/gnu/packages/lisp.scm
@@ -1341,3 +1341,50 @@ compressor.  It works on data produced by @code{parse-js} to generate a
 @item remove some unreachable code
 @end itemize\n")
       (license license:zlib))))
+
+(define-public uglify-js
+  (package
+    (inherit sbcl-cl-uglify-js)
+    (name "uglify-js")
+    (build-system trivial-build-system)
+    (arguments
+     `(#:modules ((guix build utils))
+       #:builder
+       (let* ((bin    (string-append (assoc-ref %outputs "out") "/bin/"))
+              (script (string-append bin "uglify-js")))
+         (use-modules (guix build utils))
+         (mkdir-p bin)
+         (with-output-to-file script
+           (lambda _
+             (format #t "#!~a/bin/sbcl --script
+ (require :asdf)
+ (push (truename \"~a/lib/sbcl\") asdf:*central-registry*)"
+                     (assoc-ref %build-inputs "sbcl")
+                     (assoc-ref %build-inputs "sbcl-cl-uglify-js"))
+             ;; FIXME: cannot use progn here because otherwise it fails to
+             ;; find cl-uglify-js.
+             (for-each
+              write
+              '(;; Quiet, please!
+                (let ((*standard-output* (make-broadcast-stream))
+                      (*error-output* (make-broadcast-stream)))
+                  (asdf:load-system :cl-uglify-js))
+                (let ((file (cadr *posix-argv*)))
+                  (if file
+                      (format t "~a"
+                              (cl-uglify-js:ast-gen-code
+                               (cl-uglify-js:ast-mangle
+                                (cl-uglify-js:ast-squeeze
+                                 (with-open-file (in file)
+                                                 (parse-js:parse-js in))))
+                               :beautify nil))
+                      (progn
+                       (format *error-output*
+                               "Please provide a JavaScript file.~%")
+                       (sb-ext:exit :code 1))))))))
+         (chmod script #o755)
+         #t)))
+    (inputs
+     `(("sbcl" ,sbcl)
+       ("sbcl-cl-uglify-js" ,sbcl-cl-uglify-js)))
+    (synopsis "JavaScript compressor")))
-- 
2.12.2

  parent reply	other threads:[~2017-05-29 17:22 UTC|newest]

Thread overview: 15+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2017-05-29 16:53 bug#27132: [PATCH 0/6] Add uglify-js Ricardo Wurmus
2017-05-29 17:21 ` bug#27132: [PATCH 1/6] gnu: Add sbcl-cl-ppcre-unicode Ricardo Wurmus
2017-05-29 17:21   ` bug#27132: [PATCH 2/6] gnu: Add sbcl-parse-js Ricardo Wurmus
2017-06-01 12:00     ` Ludovic Courtès
2017-05-29 17:21   ` bug#27132: [PATCH 3/6] gnu: Add sbcl-parse-number Ricardo Wurmus
2017-06-01 12:01     ` Ludovic Courtès
2017-05-29 17:21   ` bug#27132: [PATCH 4/6] gnu: Add sbcl-iterate Ricardo Wurmus
2017-06-01 12:01     ` Ludovic Courtès
2017-05-29 17:21   ` bug#27132: [PATCH 5/6] gnu: Add sbcl-cl-uglify-js Ricardo Wurmus
2017-06-01 12:02     ` Ludovic Courtès
2017-05-29 17:21   ` Ricardo Wurmus [this message]
2017-06-01 12:03     ` bug#27132: [PATCH 6/6] gnu: Add uglify-js Ludovic Courtès
2017-06-01 21:33       ` Ricardo Wurmus
2017-06-02 19:00       ` Arun Isaac
2017-06-01 12:00   ` bug#27132: [PATCH 1/6] gnu: Add sbcl-cl-ppcre-unicode Ludovic Courtès

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

  List information: https://guix.gnu.org/

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20170529172131.20954-6-rekado@elephly.net \
    --to=rekado@elephly.net \
    --cc=27132@debbugs.gnu.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
Code repositories for project(s) associated with this public inbox

	https://git.savannah.gnu.org/cgit/guix.git

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).