Skip to content
Permalink

Comparing changes

Choose two branches to see what’s changed or to start a new pull request. If you need to, you can also or learn more about diff comparisons.

Open a pull request

Create a new pull request by comparing changes across two branches. If you need to, you can also . Learn more about diff comparisons here.
base repository: opal/opal
Failed to load repositories. Confirm that selected base ref is valid, then try again.
Loading
base: fc199b5e2e1e
Choose a base ref
...
head repository: opal/opal
Failed to load repositories. Confirm that selected head ref is valid, then try again.
Loading
compare: af7057cb2a1e
Choose a head ref
  • 2 commits
  • 1 file changed
  • 2 contributors

Commits on Mar 23, 2014

  1. Copy the full SHA
    cbab045 View commit details
  2. Merge pull request #518 from davispuh/util_fix_win

    Fix Util module to work on Windows
    elia committed Mar 23, 2014
    Copy the full SHA
    af7057c View commit details
Showing with 12 additions and 4 deletions.
  1. +12 −4 lib/opal/util.rb
16 changes: 12 additions & 4 deletions lib/opal/util.rb
Original file line number Diff line number Diff line change
@@ -2,26 +2,34 @@ module Opal
module Util
extend self

def null
if (/mswin|mingw/ =~ RUBY_PLATFORM).nil?
'/dev/null'
else
'nul'
end
end

# Used for uglifying source to minify
def uglify(str)
IO.popen('uglifyjs 2> /dev/null', 'r+') do |i|
IO.popen('uglifyjs 2> ' + null, 'r+') do |i|
i.puts str
i.close_write
return i.read
end
rescue Errno::ENOENT, Errno::EPIPE
rescue Errno::ENOENT, Errno::EPIPE, Errno::EINVAL
$stderr.puts '"uglifyjs" command not found (install with: "npm install -g uglify-js")'
nil
end

# Gzip code to check file size
def gzip(str)
IO.popen('gzip -f 2> /dev/null', 'r+') do |i|
IO.popen('gzip -f 2> ' + null, 'r+') do |i|
i.puts str
i.close_write
return i.read
end
rescue Errno::ENOENT, Errno::EPIPE
rescue Errno::ENOENT, Errno::EPIPE, Errno::EINVAL
$stderr.puts '"gzip" command not found, it is required to produce the .gz version'
nil
end