jekyll-watch 1.5.1 → 2.0.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/lib/jekyll-watch/version.rb +1 -1
- data/lib/jekyll/commands/watch.rb +1 -11
- data/lib/jekyll/watcher.rb +26 -10
- metadata +1 -1
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 5b995f8f1937dd0830a8347c44a27f87b28325c7614854f93337583423107256
|
4
|
+
data.tar.gz: 2a275f462b1112f9993181dc1d7014b86d729fc73a092cbb99cdc71a071c11f7
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 21004c7e9c97022dbcdb58c4d10d2236c7e8f2592e60bb1539bd91645a10e8f0dbd4d926243439849e0004aa2ecb123ffda0abf81fe4abb11fa0bb268c8a0eb0
|
7
|
+
data.tar.gz: '08b6ff0a2bb1c8016f96f71d0e91ed52250ef67177a660081cc4c72b54104ad965775aef247e329fdc8e46cb3f449cc8956a59dd8dd9cd8da22e753290e6b3c9'
|
data/lib/jekyll-watch/version.rb
CHANGED
@@ -11,17 +11,7 @@ module Jekyll
|
|
11
11
|
# Continuously watch if `watch` is set to true in the config.
|
12
12
|
def process(options)
|
13
13
|
Jekyll.logger.log_level = :error if options["quiet"]
|
14
|
-
watch(
|
15
|
-
end
|
16
|
-
|
17
|
-
# Watch for file changes and rebuild the site.
|
18
|
-
#
|
19
|
-
# site - A Jekyll::Site instance
|
20
|
-
# options - A Hash of options passed to the command
|
21
|
-
#
|
22
|
-
# Returns nothing.
|
23
|
-
def watch(_site, options)
|
24
|
-
Jekyll::Watcher.watch(options)
|
14
|
+
Jekyll::Watcher.watch(options) if options["watch"]
|
25
15
|
end
|
26
16
|
|
27
17
|
end
|
data/lib/jekyll/watcher.rb
CHANGED
@@ -40,7 +40,7 @@ module Jekyll
|
|
40
40
|
# You pressed Ctrl-C, oh my!
|
41
41
|
end
|
42
42
|
|
43
|
-
|
43
|
+
private
|
44
44
|
def build_listener(site, options)
|
45
45
|
Listen.to(
|
46
46
|
options["source"],
|
@@ -50,34 +50,36 @@ module Jekyll
|
|
50
50
|
)
|
51
51
|
end
|
52
52
|
|
53
|
+
private
|
53
54
|
def listen_handler(site)
|
54
55
|
proc do |modified, added, removed|
|
55
56
|
t = Time.now
|
56
57
|
c = modified + added + removed
|
57
58
|
n = c.length
|
58
|
-
|
59
|
-
"#{n} file(s) changed at #{t.strftime("%Y-%m-%d %H:%M:%S")}
|
60
|
-
|
61
|
-
|
62
|
-
|
63
|
-
rescue => e
|
64
|
-
puts "...error:"
|
65
|
-
Jekyll.logger.warn "Error:", e.message
|
66
|
-
Jekyll.logger.warn "Error:", "Run jekyll build --trace for more information."
|
59
|
+
Jekyll.logger.info "Regenerating:",
|
60
|
+
"#{n} file(s) changed at #{t.strftime("%Y-%m-%d %H:%M:%S")}"
|
61
|
+
|
62
|
+
c.map { |path| path.sub("#{site.source}/", "") }.each do |file|
|
63
|
+
Jekyll.logger.info "", file
|
67
64
|
end
|
65
|
+
|
66
|
+
process(site, t)
|
68
67
|
end
|
69
68
|
end
|
70
69
|
|
70
|
+
private
|
71
71
|
def custom_excludes(options)
|
72
72
|
Array(options["exclude"]).map { |e| Jekyll.sanitized_path(options["source"], e) }
|
73
73
|
end
|
74
74
|
|
75
|
+
private
|
75
76
|
def config_files(options)
|
76
77
|
%w(yml yaml toml).map do |ext|
|
77
78
|
Jekyll.sanitized_path(options["source"], "_config.#{ext}")
|
78
79
|
end
|
79
80
|
end
|
80
81
|
|
82
|
+
private
|
81
83
|
def to_exclude(options)
|
82
84
|
[
|
83
85
|
config_files(options),
|
@@ -91,6 +93,7 @@ module Jekyll
|
|
91
93
|
# options - A Hash of options passed to the command
|
92
94
|
#
|
93
95
|
# Returns a list of relative paths from source that should be ignored
|
96
|
+
private
|
94
97
|
def listen_ignore_paths(options)
|
95
98
|
source = Pathname.new(options["source"]).expand_path
|
96
99
|
paths = to_exclude(options)
|
@@ -111,8 +114,21 @@ module Jekyll
|
|
111
114
|
end.compact + [%r!\.jekyll\-metadata!]
|
112
115
|
end
|
113
116
|
|
117
|
+
private
|
114
118
|
def sleep_forever
|
115
119
|
loop { sleep 1000 }
|
116
120
|
end
|
121
|
+
|
122
|
+
private
|
123
|
+
def process(site, time)
|
124
|
+
begin
|
125
|
+
site.process
|
126
|
+
Jekyll.logger.info "", "...done in #{Time.now - time} seconds."
|
127
|
+
rescue => e
|
128
|
+
Jekyll.logger.warn "Error:", e.message
|
129
|
+
Jekyll.logger.warn "Error:", "Run jekyll build --trace for more information."
|
130
|
+
end
|
131
|
+
puts ""
|
132
|
+
end
|
117
133
|
end
|
118
134
|
end
|