[DRE-commits] [ruby-uglifier] 01/03: Use packaged UglifyJS (and Source-Map)

Antonio Terceiro terceiro at moszumanska.debian.org
Mon Aug 8 01:05:09 UTC 2016


This is an automated email from the git hooks/post-receive script.

terceiro pushed a commit to branch patch-queue/master
in repository ruby-uglifier.

commit bc06752bc65cada88c9c5a19883f3708ac6d9cd7
Author: Antonio Terceiro <terceiro at debian.org>
Date:   Sun Aug 7 10:50:20 2016 -0300

    Use packaged UglifyJS (and Source-Map)
    
    This patch is Debian-specific
    
    Gbp-Pq: Name 0001-Use-packaged-UglifyJS-and-Source-Map.patch
---
 lib/uglifier.rb | 30 ++++++++++++++++++++++++------
 1 file changed, 24 insertions(+), 6 deletions(-)

diff --git a/lib/uglifier.rb b/lib/uglifier.rb
index a2b9671..7e3d7db 100644
--- a/lib/uglifier.rb
+++ b/lib/uglifier.rb
@@ -74,12 +74,21 @@ class Uglifier
     })
   JS
 
+  def self.find_asset(filename)
+    [
+          File.expand_path("../" + filename, __FILE__),
+          File.join("/usr/share/javascript/ruby-uglifier", filename)
+    ].find { |f| File.exists?(f) }
+  end
+
+  # SourceMap path
+  SourceMapPath = "/usr/share/javascript/source-map/source-map.js"
   # UglifyJS source path
-  SourcePath = File.expand_path("../uglify.js", __FILE__)
+  SourcePath = "/usr/share/javascript/uglifyjs/uglify.js"
   # ES5 shims source path
-  ES5FallbackPath = File.expand_path("../es5.js", __FILE__)
+  ES5FallbackPath = find_asset("es5.js")
   # String.split shim source path
-  SplitFallbackPath = File.expand_path("../split.js", __FILE__)
+  SplitFallbackPath = find_asset("split.js")
 
   # Default options for compilation
   DEFAULTS = {
@@ -191,9 +200,18 @@ class Uglifier
   private
 
   def uglifyjs_source
-    [ES5FallbackPath, SplitFallbackPath, SourcePath].map do |file|
-      File.open(file, "r:UTF-8") { |f| f.read }
-    end.join("\n")
+    [
+      __read__(ES5FallbackPath),
+      __read__(SplitFallbackPath),
+      'window = this;',
+      __read__(SourceMapPath),
+      "MOZ_SourceMap = sourceMap;",
+      __read__(SourcePath),
+    ].join("\n")
+  end
+
+  def __read__(file)
+    File.open(file, "r:UTF-8") { |f| f.read }
   end
 
   # Run UglifyJS for given source code

-- 
Alioth's /usr/local/bin/git-commit-notice on /srv/git.debian.org/git/pkg-ruby-extras/ruby-uglifier.git



More information about the Pkg-ruby-extras-commits mailing list