Sha256: 3ee4cc2ffaa88638487c7459d8965445d17fdd3146da6acfd081035e9fd4d810

Contents?: true

Size: 1.8 KB

Versions: 23

Compression:

Stored size: 1.8 KB

Contents

# ------------------------------------------------------------------------------
# ~/_plugins/symlink_watcher
# jekyll-watch extension to listen for changes in symlinked folders
#
# Product/Info:
# https://github.com/willnorris/willnorris.com/tree/master/src/_plugins/
# https://jekyll.one
#
# Copyright (C) 2002-2014 Will Norris
# Copyright (C) 2020 Juergen Adams
#
# symlink_watcher is licensed under the  MIT license
# See: https://github.com/willnorris/willnorris.com/blob/master/LICENSE
# J1 Template is licensed under the MIT License.
# See: https://github.com/jekyll-one-org/J1 Template/blob/master/LICENSE
#
# ------------------------------------------------------------------------------
# NOTE:
#   The symlink_watcher plugin extends jekyll-watch to listen also
#   for changes in any symlinked sub-directory.
#
#   For example, in _drafts directory is a symlink to a directory 
#   elsewhere on the filesystem. This plugin will cause jekyll to 
#   regenerate the site when ANY file change in the drafts folder.
# ------------------------------------------------------------------------------
require "find"
require "jekyll-watch"

module Jekyll
  module Watcher
    def build_listener_with_symlinks(site, options)
      src = options["source"]
      dirs = [src]
      Find.find(src).each do |f|
        next if f == "#{src}/_drafts" and not options["show_drafts"]
        # TODO: willnorris, filter ignored files
        dirs << f if File.directory?(f) and File.symlink?(f)
      end

      require "listen"
      Listen.to(
        *dirs,
        :ignore => listen_ignore_paths(options),
        :force_polling => options['force_polling'],
        &(listen_handler(site))
      )
    end

    alias_method :build_listener_without_symlinks, :build_listener
    alias_method :build_listener, :build_listener_with_symlinks
  end
end

Version data entries

23 entries across 23 versions & 1 rubygems

Version Path
j1-template-2020.0.22 lib/starter_web/_plugins/symlink_watcher.rb
j1-template-2020.0.21 lib/starter_web/_plugins/symlink_watcher.rb
j1-template-2020.0.20 lib/starter_web/_plugins/symlink_watcher.rb
j1-template-2020.0.19 lib/starter_web/_plugins/symlink_watcher.rb
j1-template-2020.0.18 lib/starter_web/_plugins/symlink_watcher.rb
j1-template-2020.0.17 lib/starter_web/_plugins/symlink_watcher.rb
j1-template-2020.0.16 lib/starter_web/_plugins/symlink_watcher.rb
j1-template-2020.0.15 lib/starter_web/_plugins/symlink_watcher.rb
j1-template-2020.0.14 lib/starter_web/_plugins/symlink_watcher.rb
j1-template-2020.0.13 lib/starter_web/_plugins/symlink_watcher.rb
j1-template-2020.0.12 lib/starter_web/_plugins/symlink_watcher.rb
j1-template-2020.0.11 lib/starter_web/_plugins/symlink_watcher.rb
j1-template-2020.0.10 lib/starter_web/_plugins/symlink_watcher.rb
j1-template-2020.0.9 lib/starter_web/_plugins/symlink_watcher.rb
j1-template-2020.0.8 lib/starter_web/_plugins/symlink_watcher.rb
j1-template-2020.0.7 lib/starter_web/_plugins/symlink_watcher.rb
j1-template-2020.0.6 lib/starter_web/_plugins/symlink_watcher.rb
j1-template-2020.0.5 lib/starter_web/_plugins/symlink_watcher.rb
j1-template-2020.0.4 lib/starter_web/_plugins/symlink_watcher.rb
j1-template-2020.0.3 lib/starter_web/_plugins/symlink_watcher.rb