Skip to content

Commit

Permalink
Enforcing delaying minification of CSS and Javascript.
Browse files Browse the repository at this point in the history
Removing undefined method yui_command from 
build_inline_javascript which caused build failure.

MANIFEST.build_root never matched dst_path
(one was /staging and one was /build)
  • Loading branch information
Jason Ketterman authored and Charles Jolley committed Jan 14, 2010
1 parent 2094fe7 commit 7511e14
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 45 deletions.
51 changes: 8 additions & 43 deletions lib/sproutcore/builders/minify.rb
Original file line number Diff line number Diff line change
Expand Up @@ -33,64 +33,29 @@ def build(dst_path)
end

def build_css(dst_path)
a = Regexp.new('^'+MANIFEST.build_root)
if dst_path =~ a
$to_minify= $to_minify+" "+dst_path
FileUtils.mkdir_p(File.dirname(dst_path))
FileUtils.copy(entry.source_path, dst_path)
else
yui_root = File.expand_path(File.join(LIBPATH, '..', 'vendor', 'yui-compressor'))
jar_path = File.join(yui_root, 'yuicompressor-2.4.2.jar')
FileUtils.mkdir_p(File.dirname(dst_path)) # make sure loc exists...
filecompress = "java -jar " + jar_path + " --charset utf-8 --line-break 0 --nomunge --preserve-semi --disable-optimizations " + entry.source_path + " -o \"" + dst_path + "\" 2>&1"
SC.logger.info 'Compressing CSS with YUI .... '+ dst_path
SC.logger.debug `#{filecompress}`

if $?.exitstatus != 0
_report_error(output, entry.filename, entry.source_path)
SC.logger.fatal("!!!!YUI compressor failed, please check that your css code is valid.")
SC.logger.fatal("!!!!Failed compressing CSS... "+ dst_path)
end
end
$to_minify= $to_minify+" "+dst_path
FileUtils.mkdir_p(File.dirname(dst_path))
FileUtils.copy(entry.source_path, dst_path)
end

# Minify some javascript by invoking the YUI compressor.
def build_javascript(dst_path)
a = Regexp.new('^'+MANIFEST.build_root)
if dst_path =~ a
$to_minify= $to_minify+" "+dst_path
FileUtils.mkdir_p(File.dirname(dst_path))
FileUtils.copy(entry.source_path, dst_path)
else
yui_root = File.expand_path(File.join(LIBPATH, '..', 'vendor', 'yui-compressor'))
jar_path = File.join(yui_root, 'yuicompressor-2.4.2.jar')
FileUtils.mkdir_p(File.dirname(dst_path)) # make sure loc exists...
filecompress = "java -jar " + jar_path + " --charset utf-8 --line-break 80 " + entry.source_path + " -o \"" + dst_path + "\" 2>&1"
SC.logger.info 'Compressing with YUI: '+ dst_path + "..."

output = `#{filecompress}` # It'd be nice to just read STDERR, but
# I can't find a reasonable, commonly-
# installed, works-on-all-OSes solution.
if $?.exitstatus != 0
_report_error(output, entry.filename, entry.source_path)
SC.logger.fatal("!!!!YUI compressor failed, please check that your js code is valid")
SC.logger.fatal("!!!!Failed compressing ... "+ dst_path)
end
end
$to_minify= $to_minify+" "+dst_path
FileUtils.mkdir_p(File.dirname(dst_path))
FileUtils.copy(entry.source_path, dst_path)
end

def build_inline_javascript(dst_path)
SC.logger.info 'Compressing inline Javascript with YUI: ' + dst_path + "..."
system(yui_command('--line-break 0', dst_path))
yui_root = File.expand_path(File.join(LIBPATH, '..', 'vendor', 'yui-compressor'))
jar_path = File.join(yui_root, 'yuicompressor-2.4.2.jar')
FileUtils.mkdir_p(File.dirname(dst_path)) # make sure loc exists...
filecompress = "java -jar " + jar_path + " --charset utf-8 --line-break 80 " + entry.source_path + " -o \"" + dst_path + "\" 2>&1"
SC.logger.info 'Compressing with YUI: '+ dst_path + "..."

output = `#{filecompress}` # It'd be nice to just read STDERR, but
# I can't find a reasonable, commonly-
# installed, works-on-all-OSes solution.
# I can't find a reasonable, commonly-
# installed, works-on-all-OSes solution.
if $?.exitstatus != 0
_report_error(output, entry.filename, entry.source_path)
SC.logger.fatal("!!!!YUI compressor failed, please check that your js code is valid")
Expand Down
4 changes: 2 additions & 2 deletions lib/sproutcore/tools/build.rb
Original file line number Diff line number Diff line change
Expand Up @@ -82,8 +82,8 @@ def build(*targets)
SC.logger.info 'Compressing with YUI: '+ $to_minify + "..."

output = `#{filecompress}` # It'd be nice to just read STDERR, but
# I can't find a reasonable, commonly-
# installed, works-on-all-OSes solution.
# I can't find a reasonable, commonly-
# installed, works-on-all-OSes solution.
SC.logger.info output
if $?.exitstatus != 0
SC.logger.fatal(output)
Expand Down

0 comments on commit 7511e14

Please sign in to comment.