allow setting a destination_dir for SourceWatchers

This change lets a source be defined with a destination directory. That way we can mount a source (say a gem’s ‘doc’ directory) in a namespace and worry less about name collisions with  files in other sources.
This commit is contained in:
Steven Sloan 2015-04-17 13:28:23 -04:00
parent f61e08a9c3
commit 3b1a00cf47
5 changed files with 17 additions and 2 deletions

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