module Opal::Util
Constants
- ExitStatusError
Public Instance Methods
gzip(source)
click to toggle source
Gzip code to check file size.
# File lib/opal/util.rb, line 22 def gzip(source) sh 'gzip -f', data: source end
uglify(source, mangle: false)
click to toggle source
Used for uglifying source to minify.
Opal::Util.uglify("javascript contents")
@param str [String] string to minify @return [String]
# File lib/opal/util.rb, line 17 def uglify(source, mangle: false) sh "#{'ruby ' if Gem.win_platform?}bin/yarn -s run terser -c #{'-m' if mangle}", data: source end
Private Instance Methods
sh(command, data:)
click to toggle source
# File lib/opal/util.rb, line 28 def sh(command, data:) out, _err, status = Open3.capture3(command, stdin_data: data) raise ExitStatusError, "exited with status #{status.exitstatus}" unless status.success? out end