From 6cee2a87ccb4a3d09f27af6d5a672485687aa500 Mon Sep 17 00:00:00 2001 From: Parker Moore Date: Sat, 30 Aug 2014 16:18:29 -0700 Subject: [PATCH] Auto-enable watch on 'serve'. Addresses @kneath's and @chibicode's comments in #2695. --- Rakefile | 2 +- lib/jekyll/command.rb | 2 +- lib/jekyll/commands/serve.rb | 3 ++- lib/jekyll/configuration.rb | 2 +- 4 files changed, 5 insertions(+), 4 deletions(-) diff --git a/Rakefile b/Rakefile index 7f352395..74a0ee42 100644 --- a/Rakefile +++ b/Rakefile @@ -146,7 +146,7 @@ namespace :site do # Generate the site in server mode. puts "Running Jekyll..." Dir.chdir("site") do - sh "#{File.expand_path('bin/jekyll', File.dirname(__FILE__))} serve --watch" + sh "#{File.expand_path('bin/jekyll', File.dirname(__FILE__))} serve" end end diff --git a/lib/jekyll/command.rb b/lib/jekyll/command.rb index bf6d981d..a1cc8c01 100644 --- a/lib/jekyll/command.rb +++ b/lib/jekyll/command.rb @@ -51,7 +51,7 @@ module Jekyll c.option 'config', '--config CONFIG_FILE[,CONFIG_FILE2,...]', Array, 'Custom configuration file' c.option 'future', '--future', 'Publishes posts with a future date' c.option 'limit_posts', '--limit_posts MAX_POSTS', Integer, 'Limits the number of posts to parse and publish' - c.option 'watch', '-w', '--watch', 'Watch for changes and rebuild' + c.option 'watch', '-w', '--[no-]watch', 'Watch for changes and rebuild' c.option 'force_polling', '--force_polling', 'Force watch to use polling' c.option 'lsi', '--lsi', 'Use LSI for improved related posts' c.option 'show_drafts', '-D', '--drafts', 'Render posts in the _drafts folder' diff --git a/lib/jekyll/commands/serve.rb b/lib/jekyll/commands/serve.rb index 2fbfd74c..fc18634c 100644 --- a/lib/jekyll/commands/serve.rb +++ b/lib/jekyll/commands/serve.rb @@ -20,7 +20,8 @@ module Jekyll c.option 'skip_initial_build', '--skip-initial-build', 'Skips the initial site build which occurs before the server is started.' c.action do |args, options| - options["serving"] ||= true + options["serving"] = true + options["watch"] = true unless options.key?("watch") Jekyll::Commands::Build.process(options) Jekyll::Commands::Serve.process(options) end diff --git a/lib/jekyll/configuration.rb b/lib/jekyll/configuration.rb index 7fb0d8f5..8a1d7323 100644 --- a/lib/jekyll/configuration.rb +++ b/lib/jekyll/configuration.rb @@ -211,7 +211,7 @@ module Jekyll if config.key?('auto') || config.key?('watch') Jekyll.logger.warn "Deprecation:", "Auto-regeneration can no longer" + " be set from your configuration file(s). Use the"+ - " --watch/-w command-line option instead." + " --[no-]watch/-w command-line option instead." config.delete('auto') config.delete('watch') end