Skip to content
This repository has been archived by the owner on Nov 9, 2022. It is now read-only.

Commit

Permalink
Download compiled jQuery rather than compile it directly [#153]
Browse files Browse the repository at this point in the history
  • Loading branch information
ebollens committed Jan 3, 2013
1 parent fcdc2c5 commit 457024b
Showing 1 changed file with 20 additions and 21 deletions.
41 changes: 20 additions & 21 deletions lib/Build/Package/Jquery.rb
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
require 'rubygems'
require 'extensions/kernel'
require 'net/http'
require_relative '../../Path'
require_relative '../Submodule'
require_relative '../Utilities'
Expand All @@ -13,25 +14,19 @@ module Package

class Jquery

def domain
'code.jquery.com'
end

def path
config[:build][:debug] ? '/jquery-1.8.3.js' : '/jquery-1.8.3.min.js'
end

include ::WebBlocks::Logger
include ::WebBlocks::Path::Temporary_Build
include ::WebBlocks::Build::Submodule
include ::WebBlocks::Build::Utilities

def preprocess

preprocess_js

end

def preprocess_js

preprocess_submodule :jquery
preprocess_submodule_submodules :jquery
preprocess_submodule_npm :jquery

end

def compile

compile_js
Expand All @@ -40,15 +35,19 @@ def compile

def compile_js

unless File.exists? "#{package_dir :jquery}/dist/jquery.js"
filename = "#{package_dir :jquery}/dist/jquery.js"

unless File.exists? filename

log.task "Package: jQuery", "Compiling jQuery" do
Dir.chdir package_dir :jquery do
status, stdout, stderr = systemu "#{config[:exec][:npm]} install"
log.failure "Builder: jQuery", "NPM execution failed" if stderr.length > 0
status, stdout, stderr = systemu "#{config[:exec][:grunt]}"
log.failure "Builder: jQuery", "Grunt execution failed" if stderr.length > 0
log.task "Package: jQuery", "Downloading compiled version of jQuery" do
Net::HTTP.start(domain) do |http|
resp = http.get(path)
FileUtils.mkdir_p File.dirname(filename)
open(filename, "w") do |file|
file.write(resp.body)
end
end

end

end
Expand Down

0 comments on commit 457024b

Please sign in to comment.