lib/sass/exec/sass_convert.rb in sass-3.4.21 vs lib/sass/exec/sass_convert.rb in sass-3.4.22
- old
+ new
@@ -155,10 +155,14 @@
opts.on('-C', '--no-cache', "Don't cache to sassc files.") do
@options[:for_engine][:read_cache] = false
end
+ opts.on('-q', '--quiet', 'Silence warnings and status messages during conversion.') do |bool|
+ @options[:for_engine][:quiet] = bool
+ end
+
opts.on('--trace', :NONE, 'Show a full Ruby stack trace on error') do
@options[:trace] = true
end
end
@@ -241,16 +245,16 @@
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])
+ Sass::CSS.new(read(input), @options[:for_tree]).render(@options[:to])
else
if input_path
Sass::Engine.for_file(input_path, @options[:for_engine])
else
- Sass::Engine.new(input.read, @options[:for_engine])
+ Sass::Engine.new(read(input), @options[:for_engine])
end.to_tree.send("to_#{@options[:to]}", @options[:for_tree])
end
end
output = input_path if @options[:in_place]
@@ -264,8 +268,16 @@
end
def path_for(file)
return file.path if file.is_a?(File)
return file if file.is_a?(String)
+ end
+
+ def read(file)
+ if file.respond_to?(:read)
+ file.read
+ else
+ open(file, 'rb') {|f| f.read}
+ end
end
end
end