add `bundle install` to `jekyll new`
- automatically run `bundle install` from within the newly generated blog directory by default. - add a new switch to skip this default behaviour.
This commit is contained in:
parent
55de780520
commit
566b42b8b3
|
@ -11,6 +11,7 @@ module Jekyll
|
||||||
|
|
||||||
c.option "force", "--force", "Force creation even if PATH already exists"
|
c.option "force", "--force", "Force creation even if PATH already exists"
|
||||||
c.option "blank", "--blank", "Creates scaffolding but with empty files"
|
c.option "blank", "--blank", "Creates scaffolding but with empty files"
|
||||||
|
c.option "skip-bundle", "--skip-bundle", "Skip 'bundle install'"
|
||||||
|
|
||||||
c.action do |args, options|
|
c.action do |args, options|
|
||||||
Jekyll::Commands::New.process(args, options)
|
Jekyll::Commands::New.process(args, options)
|
||||||
|
@ -34,7 +35,7 @@ module Jekyll
|
||||||
create_site new_blog_path
|
create_site new_blog_path
|
||||||
end
|
end
|
||||||
|
|
||||||
Jekyll.logger.info "New jekyll site installed in #{new_blog_path.cyan}."
|
after_install(new_blog_path, options)
|
||||||
end
|
end
|
||||||
|
|
||||||
def create_blank_site(path)
|
def create_blank_site(path)
|
||||||
|
@ -114,6 +115,27 @@ RUBY
|
||||||
def scaffold_path
|
def scaffold_path
|
||||||
"_posts/0000-00-00-welcome-to-jekyll.markdown.erb"
|
"_posts/0000-00-00-welcome-to-jekyll.markdown.erb"
|
||||||
end
|
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
|
end
|
||||||
end
|
end
|
||||||
|
|
Loading…
Reference in New Issue