Merge pull request #4542 from jekyll/jekyll-new-with-gemfile
Merge pull request 4542
This commit is contained in:
commit
87d0f03f5c
|
@ -35,6 +35,10 @@ module Jekyll
|
|||
File.open(File.expand_path(initialized_post_name, new_blog_path), "w") do |f|
|
||||
f.write(scaffold_post_content)
|
||||
end
|
||||
|
||||
File.open(File.expand_path("Gemfile", new_blog_path), "w") do |f|
|
||||
f.write(gemfile_contents)
|
||||
end
|
||||
end
|
||||
|
||||
Jekyll.logger.info "New jekyll site installed in #{new_blog_path}."
|
||||
|
@ -60,6 +64,31 @@ module Jekyll
|
|||
|
||||
private
|
||||
|
||||
def gemfile_contents
|
||||
<<-RUBY
|
||||
source "https://rubygems.org"
|
||||
|
||||
# Hello! This is where you manage which Jekyll version is used to run.
|
||||
# When you want to use a different version, change it below, save the
|
||||
# file and run `bundle install`. Run Jekyll with `bundle exec`, like so:
|
||||
#
|
||||
# bundle exec jekyll serve
|
||||
#
|
||||
# This will help ensure the proper Jekyll version is running.
|
||||
# Happy Jekylling!
|
||||
gem "jekyll", "#{Jekyll::VERSION}"
|
||||
|
||||
# If you want to use GitHub Pages, remove the "gem "jekyll"" above and
|
||||
# uncomment the line below. To upgrade, run `bundle update github-pages`.
|
||||
# gem "github-pages", group: :jekyll_plugins
|
||||
|
||||
# If you have any plugins, put them here!
|
||||
# group :jekyll_plugins do
|
||||
# gem "jekyll-github-metadata", "~> 1.0"
|
||||
# end
|
||||
RUBY
|
||||
end
|
||||
|
||||
def preserve_source_location?(path, options)
|
||||
!options["force"] && !Dir["#{path}/**/*"].empty?
|
||||
end
|
||||
|
|
|
@ -29,6 +29,15 @@ class TestNewCommand < JekyllUnitTest
|
|||
assert_exist @full_path
|
||||
end
|
||||
|
||||
should "create a Gemfile" do
|
||||
gemfile = File.join(@full_path, "Gemfile")
|
||||
refute_exist @full_path
|
||||
capture_stdout { Jekyll::Commands::New.process(@args) }
|
||||
assert_exist gemfile
|
||||
assert_match /gem "jekyll", "#{Jekyll::VERSION}"/, File.read(gemfile)
|
||||
assert_match /gem "github-pages"/, File.read(gemfile)
|
||||
end
|
||||
|
||||
should 'display a success message' do
|
||||
Jekyll::Commands::New.process(@args)
|
||||
output = Jekyll.logger.messages.last
|
||||
|
@ -40,6 +49,7 @@ class TestNewCommand < JekyllUnitTest
|
|||
static_template_files = dir_contents(site_template).reject do |f|
|
||||
File.extname(f) == '.erb'
|
||||
end
|
||||
static_template_files << "/Gemfile"
|
||||
|
||||
capture_stdout { Jekyll::Commands::New.process(@args) }
|
||||
|
||||
|
|
Loading…
Reference in New Issue