class Middleman::Cli::GlobAction

def execute!

Returns:
  • (void) -
def execute!
  # Sort order, images, fonts, js/css and finally everything else.
  sort_order = %w(.png .jpeg .jpg .gif .bmp .svg .svgz .ico .woff .otf .ttf .eot .js .css)
  
  # Pre-request CSS to give Compass a chance to build sprites
  puts "== Prerendering CSS" if @app.logging?
  @app.sitemap.resources.select do |resource|
    resource.ext == ".css"
  end.each do |resource|
    Middleman::Cli::Build.shared_rack.get(URI.escape(resource.destination_path))
  end
  
  puts "== Checking for Compass sprites" if @app.logging?
  # Double-check for compass sprites
  @app.files.find_new_files(File.join(@app.source_dir, @app.images_dir))
  # Sort paths to be built by the above order. This is primarily so Compass can
  # find files in the build folder when it needs to generate sprites for the
  # css files
  puts "== Building files" if @app.logging?
  resources = @app.sitemap.resources.sort do |a, b|
    a_idx = sort_order.index(a.ext) || 100
    b_idx = sort_order.index(b.ext) || 100
    a_idx <=> b_idx
  end
  # Loop over all the paths and build them.
  resources.each do |resource|
    next if @config[:glob] && !File.fnmatch(@config[:glob], resource.destination_path)
    output_path = base.render_to_file(resource)
    @cleaning_queue.delete(Pathname.new(output_path).realpath) if cleaning?
  end
end