Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 6 additions & 2 deletions lib/jekyll/watcher.rb
Original file line number Diff line number Diff line change
Expand Up @@ -100,9 +100,13 @@ def to_exclude(options)
def listen_ignore_paths(options)
source = Pathname.new(options["source"]).expand_path
paths = to_exclude(options)
convert_to_regex(paths, options, source).compact + [%r!^\.jekyll\-metadata!]
end

paths.map do |p|
def convert_to_regex(paths, options, source)
paths.flat_map do |p|
absolute_path = Pathname.new(normalize_encoding(p, options["source"].encoding)).expand_path
next convert_to_regex(Dir.glob(p), options, source) if p.include?("*")
next unless absolute_path.exist?

begin
Expand All @@ -116,7 +120,7 @@ def listen_ignore_paths(options)
rescue ArgumentError
# Could not find a relative path
end
end.compact + [%r!^\.jekyll\-metadata!]
end
end

def sleep_forever
Expand Down
29 changes: 29 additions & 0 deletions spec/watcher_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -126,6 +126,35 @@
end
end

context "with excluded globs" do
let(:excluded) { ["foo/**/*"] }
let(:excluded_relative_paths) do
["foo/bar/sit.md", "foo/lore/sit.md", "foo/barsite.md"]
end
let(:excluded_absolute_dirs) do
["foo", "foo/bar", "foo/lore"].map do |path|
Jekyll.sanitized_path(options["source"], path)
end
end
let(:excluded_absolute_files) do
excluded_relative_paths.map { |p| Jekyll.sanitized_path(options["source"], p) }
end
let(:options) { base_opts.merge("exclude" => excluded) }
before(:each) do
FileUtils.mkdir_p(excluded_absolute_dirs)
FileUtils.touch(excluded_absolute_files)
end
after(:each) do
FileUtils.rm_rf(excluded_absolute_files + excluded_absolute_dirs)
end

it "ignores the excluded files" do
excluded_relative_paths.each do |path|
expect(ignore_path?(ignored, path)).to eql(true)
end
end
end

context "with a custom destination" do
let(:default_ignored) { [%r!^_config\.yml!, %r!^_dest/!, %r!^\.jekyll\-metadata!] }

Expand Down