1
0
Fork 0
mirror of https://github.com/middleman/middleman.git synced 2022-11-09 12:20:27 -05:00

Merge pull request #1498 from stevenosloan/allow_setting_destination_directory_for_source_watchers

allow setting a destination_dir for SourceWatcher(s)
This commit is contained in:
Thomas Reynolds 2015-04-17 15:03:29 -07:00
commit 40e01b0b21
5 changed files with 17 additions and 2 deletions

View file

@ -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"

View file

@ -0,0 +1,2 @@
files.watch :source, path: File.join(root, 'source2'),
destination_dir: 'source2'

View file

@ -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