Sha256: 801000116755df28b67a9e696f9b4ecc730984288aa3bcd9502310a5f97da875

Contents?: true

Size: 941 Bytes

Versions: 1

Compression:

Stored size: 941 Bytes

Contents

module ::StaticCms::Commands
  require 'fileutils'
  require 'ruby_patch'
  extend ::RubyPatch::AutoLoad

  SITE_TEMPLATE_DIR = File.join(__DIR__, '..', '..', 'data', 'site_template')

  def self.init(dir = '.')
    FileUtils.mkdir_p(dir)
    success = false
    FileUtils.cd(dir){|dir|
      success = system <<-EOS
git init > #{File::NULL}
git commit --allow-empty -m 'Empty commit.' > #{File::NULL}
cp -r #{File.join(SITE_TEMPLATE_DIR, '*')} . > #{File::NULL}
git add . > #{File::NULL}
git commit -m 'Copied from site template.' > #{File::NULL}
      EOS
    }

    success
  end

  def self.update
    site_template_dir = File.join(__DIR__, '../data/site_template')
    FileUtils.cp_r(File.join(site_template_dir, 'templates'), '.')
    FileUtils.cp_r(File.join(site_template_dir, 'sources'), '.')
    FileUtils.cp_r(File.join(site_template_dir, 'statics'), '.')
    FileUtils.cp(File.join(site_template_dir, 'rakefile'), '.')
  end
end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
static_cms-1.2.0 lib/static_cms/commands.rb