lib/sass/exec/sass_scss.rb in sass-3.4.4 vs lib/sass/exec/sass_scss.rb in sass-3.4.5
- old
+ new
@@ -287,10 +287,31 @@
File #{@args[1]} #{err}.
Did you mean: #{@default_syntax} #{flag} #{@args[0]}:#{@args[1]}
MSG
end
+ # Watch the working directory for changes without adding it to the load
+ # path. This preserves the pre-3.4 behavior when the working directory was
+ # on the load path. We should remove this when we can look for directories
+ # to watch by traversing the import graph.
+ class << Sass::Plugin.compiler
+ # We have to use a class var to make this visible to #watched_file? and
+ # #watched_paths.
+ # rubocop:disable ClassVars
+ @@working_directory = Sass::Util.realpath('.').to_s
+ # rubocop:ensable ClassVars
+
+ def watched_file?(file)
+ super(file) ||
+ (file =~ /\.s[ac]ss$/ && file.start_with?(@@working_directory + File::SEPARATOR))
+ end
+
+ def watched_paths
+ @watched_paths ||= super + [@@working_directory]
+ end
+ end
+
dirs, files = @args.map {|name| split_colon_path(name)}.
partition {|i, _| File.directory? i}
files.map! do |from, to|
to ||= from.gsub(/\.[^.]*?$/, '.css')
sourcemap = Sass::Util.sourcemap_name(to) if @options[:sourcemap]
@@ -382,11 +403,10 @@
else
write_output(engine.render, output)
end
rescue Sass::SyntaxError => e
write_output(Sass::SyntaxError.exception_to_css(e), output) if output.is_a?(String)
- raise e if @options[:trace]
- raise e.sass_backtrace_str("standard input")
+ raise e
ensure
output.close if output.is_a? File
end
def colon_path?(path)