Commit 280f0973 by Calen Pennington

Batched coffee --watch compilation in smaller batches

This is to work around an OSx issue that causes EMFILE errors in the
default configuration.
Ref: https://github.com/joyent/node/issues/2479
parent fca63f06
...@@ -13,7 +13,22 @@ def xmodule_cmd(watch=false, debug=false) ...@@ -13,7 +13,22 @@ def xmodule_cmd(watch=false, debug=false)
end end
def coffee_cmd(watch=false, debug=false) def coffee_cmd(watch=false, debug=false)
"node_modules/.bin/coffee #{watch ? '--watch' : ''} --compile */static" if watch
# On OSx, coffee fails with EMFILE when
# trying to watch all of our coffee files at the same
# time.
#
# Ref: https://github.com/joyent/node/issues/2479
#
# Instead, watch 50 files per process in parallel
cmds = []
Dir['*/static/**/*.coffee'].each_slice(50) do |coffee_files|
cmds << "node_modules/.bin/coffee --watch --compile #{coffee_files.join(' ')}"
end
cmds
else
'node_modules/.bin/coffee --compile */static'
end
end end
def sass_cmd(watch=false, debug=false) def sass_cmd(watch=false, debug=false)
...@@ -43,8 +58,12 @@ namespace :assets do ...@@ -43,8 +58,12 @@ namespace :assets do
desc "Compile all #{asset_type} assets" desc "Compile all #{asset_type} assets"
task asset_type => prereq_task do task asset_type => prereq_task do
cmd = send(asset_type.to_s + "_cmd", watch=false, debug=false) cmd = send(asset_type.to_s + "_cmd", watch=false, debug=false)
if cmd.kind_of?(Array)
cmd.each {|c| sh(c)}
else
sh(cmd) sh(cmd)
end end
end
multitask :all => asset_type multitask :all => asset_type
multitask :debug => "assets:#{asset_type}:debug" multitask :debug => "assets:#{asset_type}:debug"
...@@ -65,10 +84,14 @@ namespace :assets do ...@@ -65,10 +84,14 @@ namespace :assets do
task :_watch => prereq_task do task :_watch => prereq_task do
cmd = send(asset_type.to_s + "_cmd", watch=true, debug=true) cmd = send(asset_type.to_s + "_cmd", watch=true, debug=true)
if cmd.kind_of?(Array)
cmd.each {|c| background_process(c)}
else
background_process(cmd) background_process(cmd)
end end
end end
end end
end
multitask :sass => 'assets:xmodule' multitask :sass => 'assets:xmodule'
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment