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:
commit
40e01b0b21
5 changed files with 17 additions and 2 deletions
|
@ -25,3 +25,11 @@ Feature: Allow multiple sources to be setup.
|
||||||
Then I should see "Data 2: Data 2"
|
Then I should see "Data 2: Data 2"
|
||||||
Then I should see "Override in Two: Overridden 2"
|
Then I should see "Override in Two: Overridden 2"
|
||||||
Then I should see "Override in One: Opposite 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"
|
||||||
|
|
|
@ -0,0 +1,2 @@
|
||||||
|
files.watch :source, path: File.join(root, 'source2'),
|
||||||
|
destination_dir: 'source2'
|
|
@ -0,0 +1 @@
|
||||||
|
Default Source
|
|
@ -0,0 +1 @@
|
||||||
|
Second Source
|
|
@ -279,8 +279,11 @@ module Middleman
|
||||||
def path_to_source_file(path)
|
def path_to_source_file(path)
|
||||||
types = Set.new([@type])
|
types = Set.new([@type])
|
||||||
|
|
||||||
::Middleman::SourceFile.new(
|
relative_path = path.relative_path_from(@directory)
|
||||||
path.relative_path_from(@directory), path, @directory, types)
|
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
|
end
|
||||||
|
|
||||||
# Notify callbacks for a file given an array of callbacks
|
# Notify callbacks for a file given an array of callbacks
|
||||||
|
|
Loading…
Reference in a new issue