From 67fc3d0c050a1cdf9db298483bc51c1ecf34ac8f Mon Sep 17 00:00:00 2001 From: inoue_sachiro Date: Wed, 30 Sep 2015 21:23:27 +0900 Subject: [PATCH] Fix: Can't clean files when the project is under a hidden directory. --- middleman-core/features/clean_build.feature | 18 ++++++++++++++++++ .../clean-app/config-hidden-dir-after.rb | 5 +++++ .../clean-app/config-hidden-dir-before.rb | 1 + middleman-core/lib/middleman-core/builder.rb | 2 +- 4 files changed, 25 insertions(+), 1 deletion(-) create mode 100644 middleman-core/fixtures/clean-app/config-hidden-dir-after.rb create mode 100644 middleman-core/fixtures/clean-app/config-hidden-dir-before.rb diff --git a/middleman-core/features/clean_build.feature b/middleman-core/features/clean_build.feature index e5254df4..eaa9942e 100644 --- a/middleman-core/features/clean_build.feature +++ b/middleman-core/features/clean_build.feature @@ -42,3 +42,21 @@ Feature: Build Clean Then the following files should not exist: | sub/dir/about.html | | sub/dir/nested/nested.html | + + Scenario: Build and clean an app under a hidden directory + Given a fixture app "clean-app" + And app "clean-app" is using config "hidden-dir-before" + And a built app at "clean-app" + Then the following files should exist: + | .build/index.html | + | .build/should_be_ignored.html | + | .build/should_be_ignored2.html | + | .build/should_be_ignored3.html | + Given app "clean-app" is using config "hidden-dir-after" + And a built app at "clean-app" + Then the following files should exist: + | .build/index.html | + And the following files should not exist: + | .build/should_be_ignored.html | + | .build/should_be_ignored2.html | + | .build/should_be_ignored3.html | diff --git a/middleman-core/fixtures/clean-app/config-hidden-dir-after.rb b/middleman-core/fixtures/clean-app/config-hidden-dir-after.rb new file mode 100644 index 00000000..454d5cf8 --- /dev/null +++ b/middleman-core/fixtures/clean-app/config-hidden-dir-after.rb @@ -0,0 +1,5 @@ +set :build_dir, ".build" + +ignore "/should_be_ignored.html" +page "/should_be_ignored2.html", :ignore => true +page "/target_ignore.html", :proxy => "/should_be_ignored3.html", :ignore => true diff --git a/middleman-core/fixtures/clean-app/config-hidden-dir-before.rb b/middleman-core/fixtures/clean-app/config-hidden-dir-before.rb new file mode 100644 index 00000000..69609a81 --- /dev/null +++ b/middleman-core/fixtures/clean-app/config-hidden-dir-before.rb @@ -0,0 +1 @@ +set :build_dir, ".build" diff --git a/middleman-core/lib/middleman-core/builder.rb b/middleman-core/lib/middleman-core/builder.rb index e386c2d0..f0a57aa1 100644 --- a/middleman-core/lib/middleman-core/builder.rb +++ b/middleman-core/lib/middleman-core/builder.rb @@ -213,7 +213,7 @@ module Middleman end @to_clean = paths.select do |path| - path.to_s !~ /\/\./ || path.to_s =~ /\.(htaccess|htpasswd)/ + path.realpath.relative_path_from(@build_dir.realpath).to_s !~ /\/\./ || path.to_s =~ /\.(htaccess|htpasswd)/ end # handle UTF-8-MAC filename on MacOS