Browse files

check for mtimes of imports without extension

  • Loading branch information...
1 parent 682b279 commit 2b81ff9c5225fe15512b693c0b09a35bbb41cf13 @grosser grosser committed Feb 17, 2010
Showing with 21 additions and 1 deletion.
  1. +8 −1 lib/less/more.rb
  2. +13 −0 test/more_test.rb
View
9 lib/less/more.rb
@@ -105,7 +105,14 @@ def mtime(file)
def mtime_including_imports(file)
mtimes = [mtime(file)]
File.readlines(file).each do |line|
- mtimes << mtime(File.join(File.dirname(file), $1)) if line =~ /^\s*@import ['"]([^'"]+)/
+ if line =~ /^\s*@import ['"]([^'"]+)/
+ imported = File.join(File.dirname(file), $1)
+ mtimes << if imported =~ /\.le?ss$/ # complete path given ?
+ mtime(imported)
+ else # we need to add .less or .lss
+ [mtime("#{imported}.less"), mtime("#{imported}.lss")].max
+ end
+ end
end
mtimes.max
end
View
13 test/more_test.rb
@@ -168,6 +168,19 @@ class MoreTest < ActiveSupport::TestCase
assert_equal 'a { color: blue; }', read_css('test.css').strip
end
+
+ should "generate for files with outdated partials that are not named .less" do
+ write_less 'test.less', "@import 'xxx/_test';"
+ write_less 'xxx/_test.less', "a{color:red}"
+ Less::More.generate_all
+
+ write_css 'test.css', 'im updated!'
+ sleep 1 # or mtime will be still the same ...
+ write_less 'xxx/_test.less', "a{color:blue}"
+ Less::More.generate_all
+
+ assert_equal 'a { color: blue; }', read_css('test.css').strip
+ end
end
end

0 comments on commit 2b81ff9

Please sign in to comment.