Class: Dotcodegen::Init

Inherits:
Object
  • Object
show all
Defined in:
lib/dotcodegen/init.rb

Class Method Summary collapse

Class Method Details

.runObject

rubocop:disable Metrics/MethodLength



6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
# File 'lib/dotcodegen/init.rb', line 6

def self.run
  source_dir = File.expand_path('../../config/default/.codegen', __dir__)
  destination_dir = File.expand_path('.codegen', Dir.pwd)

  FileUtils.mkdir_p(destination_dir) unless Dir.exist?(destination_dir)
  FileUtils.cp_r("#{source_dir}/.", destination_dir)

  instructions_dir = File.expand_path('instructions', destination_dir)
  FileUtils.mkdir_p(instructions_dir) unless Dir.exist?(instructions_dir)

  Dir.glob("#{source_dir}/instructions/*.md").each do |md_file|
    FileUtils.cp(md_file, instructions_dir)
  end

  puts 'Codegen initialized.'
  exit
end