Added --server option to start a simple WEBrick server on destination directory
This commit is contained in:
parent
ed60ad6f72
commit
9ecbfb2253
22
bin/jekyll
22
bin/jekyll
|
@ -25,6 +25,10 @@ opts = OptionParser.new do |opts|
|
||||||
options[:auto] = true
|
options[:auto] = true
|
||||||
end
|
end
|
||||||
|
|
||||||
|
opts.on("--server", "Run a WEBrick server on destination directory") do
|
||||||
|
options[:server] = true
|
||||||
|
end
|
||||||
|
|
||||||
opts.on("--lsi", "Use LSI for better related posts") do
|
opts.on("--lsi", "Use LSI for better related posts") do
|
||||||
Jekyll.lsi = true
|
Jekyll.lsi = true
|
||||||
end
|
end
|
||||||
|
@ -78,6 +82,24 @@ case ARGV.size
|
||||||
exit(1)
|
exit(1)
|
||||||
end
|
end
|
||||||
|
|
||||||
|
if options[:server]
|
||||||
|
require 'webrick'
|
||||||
|
include WEBrick
|
||||||
|
|
||||||
|
s = HTTPServer.new(
|
||||||
|
:Port => 4000,
|
||||||
|
:DocumentRoot => destination
|
||||||
|
)
|
||||||
|
t = Thread.new {
|
||||||
|
s.start
|
||||||
|
}
|
||||||
|
|
||||||
|
unless options[:auto]
|
||||||
|
trap("INT") { s.shutdown }
|
||||||
|
t.join()
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
if options[:auto]
|
if options[:auto]
|
||||||
require 'directory_watcher'
|
require 'directory_watcher'
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue