fix copying of site template files

This commit is contained in:
Daniel Grieve 2013-03-13 21:27:41 +00:00
parent 1ab83ff9e9
commit 4be5dfdb9a
3 changed files with 8 additions and 12 deletions

View File

@ -113,7 +113,7 @@ Gem::Specification.new do |s|
lib/site_template/_config.yml
lib/site_template/_layouts/default.html
lib/site_template/_layouts/post.html
lib/site_template/_posts/0000-00-00-sample_post.markdown.erb
lib/site_template/_posts/0000-00-00-welcome-to-jekyll.markdown.erb
lib/site_template/css/screen.css
lib/site_template/css/syntax.css
lib/site_template/images/.gitkeep

View File

@ -9,16 +9,16 @@ module Jekyll
new_blog_path = File.expand_path(args.join(" "), Dir.pwd)
FileUtils.mkdir_p new_blog_path
create_sample_files! new_blog_path
create_sample_files new_blog_path
File.open(File.expand_path(self.initialized_post_name, new_blog_path), "w") do |f|
f.write(self.scaffold_post_content(template_site))
f.write(self.scaffold_post_content(site_template))
end
puts "New jekyll site installed in #{new_blog_path}."
end
def self.scaffold_post_content(template_site)
ERB.new(File.read(File.expand_path(scaffold_path, template_site))).result
ERB.new(File.read(File.expand_path(scaffold_path, site_template))).result
end
# Internal: Gets the filename of the sample post to be created
@ -29,16 +29,12 @@ module Jekyll
end
private
def self.create_sample_files!(path)
FileUtils.cp_r sample_files, path
def self.create_sample_files(path)
FileUtils.cp_r site_template + '/.', path
FileUtils.rm File.expand_path(scaffold_path, path)
end
def self.sample_files
Dir.glob("#{template_site}/**/*")
end
def self.template_site
def self.site_template
File.expand_path("../../site_template", File.dirname(__FILE__))
end

View File

@ -43,7 +43,7 @@ class TestNewCommand < Test::Unit::TestCase
capture_stdout { Jekyll::Commands::New.process(@args) }
new_site_files = dir_contents(@full_path).reject do |f|
File.extname(f) == '.erb'
File.extname(f) == '.markdown'
end
assert_same_elements static_template_files, new_site_files