Only add a CODE_OF_CONDUCT.md file if specified.
This commit is contained in:
		
							parent
							
								
									4b7109d273
								
							
						
					
					
						commit
						0599f114d6
					
				|  | @ -6,20 +6,23 @@ class Jekyll::Commands::NewTheme < Jekyll::Command | |||
|       prog.command(:"new-theme") do |c| | ||||
|         c.syntax "new-theme NAME" | ||||
|         c.description "Creates a new Jekyll theme scaffold" | ||||
|         c.option "code_of_conduct", \ | ||||
|           "-c", "--code-of-conduct", \ | ||||
|           "Include a Code of Conduct. (defaults to false)" | ||||
| 
 | ||||
|         c.action do |args, _| | ||||
|           Jekyll::Commands::NewTheme.process(args) | ||||
|         c.action do |args, opts| | ||||
|           Jekyll::Commands::NewTheme.process(args, opts) | ||||
|         end | ||||
|       end | ||||
|     end | ||||
| 
 | ||||
|     def process(args) | ||||
|     def process(args, opts) | ||||
|       if !args || args.empty? | ||||
|         raise Jekyll::Errors::InvalidThemeName, "You must specify a theme name." | ||||
|       end | ||||
| 
 | ||||
|       new_theme_name = args.join("_") | ||||
|       theme = Jekyll::ThemeBuilder.new(new_theme_name) | ||||
|       theme = Jekyll::ThemeBuilder.new(new_theme_name, opts) | ||||
|       if theme.path.exist? | ||||
|         Jekyll.logger.abort_with "Conflict:", "#{theme.path} already exists." | ||||
|       end | ||||
|  |  | |||
|  | @ -3,11 +3,12 @@ class Jekyll::ThemeBuilder | |||
|     _layouts _includes _sass | ||||
|   ).freeze | ||||
| 
 | ||||
|   attr_reader :name, :path | ||||
|   attr_reader :name, :path, :code_of_conduct | ||||
| 
 | ||||
|   def initialize(theme_name) | ||||
|   def initialize(theme_name, opts) | ||||
|     @name = theme_name.to_s.tr(" ", "_").gsub(%r!_+!, "_") | ||||
|     @path = Pathname.new(File.expand_path(name, Dir.pwd)) | ||||
|     @code_of_conduct = !!opts["code_of_conduct"] | ||||
|   end | ||||
| 
 | ||||
|   def create! | ||||
|  | @ -71,7 +72,9 @@ class Jekyll::ThemeBuilder | |||
|   end | ||||
| 
 | ||||
|   def create_accessories | ||||
|     %w(README.md Rakefile CODE_OF_CONDUCT.md LICENSE.txt).each do |filename| | ||||
|     accessories = %w(README.md Rakefile LICENSE.txt) | ||||
|     accessories << "CODE_OF_CONDUCT.md" if code_of_conduct | ||||
|     accessories.each do |filename| | ||||
|       write_file(filename, template(filename)) | ||||
|     end | ||||
|   end | ||||
|  |  | |||
		Loading…
	
		Reference in New Issue