aboutsummaryrefslogtreecommitdiff
path: root/Rakefile
diff options
context:
space:
mode:
authorAndrew Lee <alee14498@gmail.com>2019-10-27 09:57:37 -0400
committerAndrew Lee <alee14498@gmail.com>2019-10-27 09:57:37 -0400
commite62e7bb6b14555c9bbe5d40d217103984f4f80e6 (patch)
tree21887d847dccacb47644eb6f74ce31326172303c /Rakefile
parent716ea6ed2b64c921a799d872a07bfbd53b2a3e58 (diff)
downloadpokeworld-website-e62e7bb6b14555c9bbe5d40d217103984f4f80e6.tar.gz
pokeworld-website-e62e7bb6b14555c9bbe5d40d217103984f4f80e6.tar.bz2
pokeworld-website-e62e7bb6b14555c9bbe5d40d217103984f4f80e6.zip
Rewrite progress
Diffstat (limited to 'Rakefile')
-rw-r--r--Rakefile76
1 files changed, 76 insertions, 0 deletions
diff --git a/Rakefile b/Rakefile
new file mode 100644
index 0000000..921330e
--- /dev/null
+++ b/Rakefile
@@ -0,0 +1,76 @@
+require "bundler/gem_tasks"
+require "jekyll"
+require "listen"
+
+def listen_ignore_paths(base, options)
+ [
+ /_config\.ya?ml/,
+ /_site/,
+ /\.jekyll-metadata/
+ ]
+end
+
+def listen_handler(base, options)
+ site = Jekyll::Site.new(options)
+ Jekyll::Command.process_site(site)
+ proc do |modified, added, removed|
+ t = Time.now
+ c = modified + added + removed
+ n = c.length
+ relative_paths = c.map{ |p| Pathname.new(p).relative_path_from(base).to_s }
+ print Jekyll.logger.message("Regenerating:", "#{relative_paths.join(", ")} changed... ")
+ begin
+ Jekyll::Command.process_site(site)
+ puts "regenerated in #{Time.now - t} seconds."
+ rescue => e
+ puts "error:"
+ Jekyll.logger.warn "Error:", e.message
+ Jekyll.logger.warn "Error:", "Run jekyll build --trace for more information."
+ end
+ end
+end
+
+task :preview do
+ base = Pathname.new('.').expand_path
+ options = {
+ "source" => base.join('test').to_s,
+ "destination" => base.join('test/_site').to_s,
+ "force_polling" => false,
+ "serving" => true,
+ "theme" => "minimal-mistakes-jekyll"
+ }
+
+ options = Jekyll.configuration(options)
+
+ ENV["LISTEN_GEM_DEBUGGING"] = "1"
+ listener = Listen.to(
+ base.join("_data"),
+ base.join("_includes"),
+ base.join("_layouts"),
+ base.join("_sass"),
+ base.join("assets"),
+ options["source"],
+ :ignore => listen_ignore_paths(base, options),
+ :force_polling => options['force_polling'],
+ &(listen_handler(base, options))
+ )
+
+ begin
+ listener.start
+ Jekyll.logger.info "Auto-regeneration:", "enabled for '#{options["source"]}'"
+
+ unless options['serving']
+ trap("INT") do
+ listener.stop
+ puts " Halting auto-regeneration."
+ exit 0
+ end
+
+ loop { sleep 1000 }
+ end
+ rescue ThreadError
+ # You pressed Ctrl-C, oh my!
+ end
+
+ Jekyll::Commands::Serve.process(options)
+end