class Sass::Exec::SassConvert
def process_file(input, output)
def process_file(input, output) if input.is_a?(File) @options[:from] ||= case input.path when /\.scss$/; :scss when /\.sass$/; :sass when /\.less$/; :less when /\.css$/; :css end elsif @options[:in_place] raise "Error: the --in-place option requires a filename." end if output.is_a?(File) @options[:to] ||= case output.path when /\.scss$/; :scss when /\.sass$/; :sass end end @options[:from] ||= :css @options[:to] ||= :sass @options[:for_engine][:syntax] = @options[:from] out = ::Sass::Util.silence_sass_warnings do if @options[:from] == :css require 'sass/css' ::Sass::CSS.new(input.read, @options[:for_tree]).render(@options[:to]) elsif @options[:from] == :less require 'sass/less' try_less_note input = input.read if input.is_a?(IO) && !input.is_a?(File) # Less is dumb Less::Engine.new(input).to_tree.to_sass_tree.send("to_#{@options[:to]}", @options[:for_tree]) else if input.is_a?(File) ::Sass::Engine.for_file(input.path, @options[:for_engine]) else ::Sass::Engine.new(input.read, @options[:for_engine]) end.to_tree.send("to_#{@options[:to]}", @options[:for_tree]) end end output = File.open(input.path, 'w') if @options[:in_place] output.write(out) rescue ::Sass::SyntaxError => e raise e if @options[:trace] file = " of #{e.sass_filename}" if e.sass_filename raise "Error on line #{e.sass_line}#{file}: #{e.message}\n Use --trace for backtrace" rescue LoadError => err handle_load_error(err) end