diff --git a/middleman-core/features/multiple-sources.feature b/middleman-core/features/multiple-sources.feature index 74b2ede4..4f23474a 100644 --- a/middleman-core/features/multiple-sources.feature +++ b/middleman-core/features/multiple-sources.feature @@ -25,3 +25,11 @@ Feature: Allow multiple sources to be setup. Then I should see "Data 2: Data 2" Then I should see "Override in Two: Overridden 2" Then I should see "Override in One: Opposite 2" + + Scenario: Set source with destination_dir + Given the Server is running at "multiple-sources-with-duplicate-file-names-app" + When I go to "/index.html" + Then I should see "Default Source" + + When I go to "/source2/index.html" + Then I should see "Second Source" diff --git a/middleman-core/fixtures/multiple-sources-with-duplicate-file-names-app/config.rb b/middleman-core/fixtures/multiple-sources-with-duplicate-file-names-app/config.rb new file mode 100644 index 00000000..d3cf8444 --- /dev/null +++ b/middleman-core/fixtures/multiple-sources-with-duplicate-file-names-app/config.rb @@ -0,0 +1,2 @@ +files.watch :source, path: File.join(root, 'source2'), + destination_dir: 'source2' \ No newline at end of file diff --git a/middleman-core/fixtures/multiple-sources-with-duplicate-file-names-app/source/index.html.erb b/middleman-core/fixtures/multiple-sources-with-duplicate-file-names-app/source/index.html.erb new file mode 100644 index 00000000..9b273182 --- /dev/null +++ b/middleman-core/fixtures/multiple-sources-with-duplicate-file-names-app/source/index.html.erb @@ -0,0 +1 @@ +Default Source \ No newline at end of file diff --git a/middleman-core/fixtures/multiple-sources-with-duplicate-file-names-app/source2/index.html.erb b/middleman-core/fixtures/multiple-sources-with-duplicate-file-names-app/source2/index.html.erb new file mode 100644 index 00000000..60e504cd --- /dev/null +++ b/middleman-core/fixtures/multiple-sources-with-duplicate-file-names-app/source2/index.html.erb @@ -0,0 +1 @@ +Second Source \ No newline at end of file diff --git a/middleman-core/lib/middleman-core/sources/source_watcher.rb b/middleman-core/lib/middleman-core/sources/source_watcher.rb index e8fc2f62..3393cd1c 100644 --- a/middleman-core/lib/middleman-core/sources/source_watcher.rb +++ b/middleman-core/lib/middleman-core/sources/source_watcher.rb @@ -279,8 +279,11 @@ module Middleman def path_to_source_file(path) types = Set.new([@type]) - ::Middleman::SourceFile.new( - path.relative_path_from(@directory), path, @directory, types) + relative_path = path.relative_path_from(@directory) + destination_dir = @options.fetch(:destination_dir, false) + relative_path = File.join(destination_dir, relative_path) if destination_dir + + ::Middleman::SourceFile.new(Pathname(relative_path), path, @directory, types) end # Notify callbacks for a file given an array of callbacks