Module: Opal::Builder::Util

Extended by:
Util
Included in:
Util
Defined in:
opal/lib/opal/builder.rb

Instance Method Summary collapse

Instance Method Details

#gzip(str) ⇒ Object

Gzip code to check file size



114
115
116
117
118
119
120
121
122
123
# File 'opal/lib/opal/builder.rb', line 114

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

#uglify(str) ⇒ Object

Used for uglifying source to minify



102
103
104
105
106
107
108
109
110
111
# File 'opal/lib/opal/builder.rb', line 102

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