diff --git a/lib/jekyll/commands/new.rb b/lib/jekyll/commands/new.rb index 90e35fee..c8569164 100644 --- a/lib/jekyll/commands/new.rb +++ b/lib/jekyll/commands/new.rb @@ -11,6 +11,7 @@ module Jekyll c.option "force", "--force", "Force creation even if PATH already exists" c.option "blank", "--blank", "Creates scaffolding but with empty files" + c.option "skip-bundle", "--skip-bundle", "Skip 'bundle install'" c.action do |args, options| Jekyll::Commands::New.process(args, options) @@ -34,7 +35,7 @@ module Jekyll create_site new_blog_path end - Jekyll.logger.info "New jekyll site installed in #{new_blog_path.cyan}." + after_install(new_blog_path, options) end def create_blank_site(path) @@ -114,6 +115,27 @@ RUBY def scaffold_path "_posts/0000-00-00-welcome-to-jekyll.markdown.erb" end + + # After a new blog has been created, print a success notification and + # then automatically execute bundle install from within the new blog dir + # unless the user opts to generate a blank blog or skip 'bundle install'. + + def after_install(path, options = {}) + Jekyll.logger.info "New jekyll site installed in #{path.cyan}." + Jekyll.logger.info "Bundle install skipped." if options["skip-bundle"] + + unless options["blank"] || options["skip-bundle"] + bundle_install path + end + end + + def bundle_install(path) + Jekyll::External.require_with_graceful_fail "bundler" + Jekyll.logger.info "Running bundle install in #{path.cyan}..." + Dir.chdir(path) do + system("bundle", "install") + end + end end end end