-
Notifications
You must be signed in to change notification settings - Fork 0
/
use_ploggy.rb
executable file
·43 lines (36 loc) · 1.11 KB
/
use_ploggy.rb
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
#!/usr/bin/env ruby
require 'fileutils'
destination_dir = nil
ARGV.each{|a|
destination_dir = a
break
}
if destination_dir == nil or not File.directory?(destination_dir)
puts "Usage: use_ploggy [destination_dir]"
exit 1
end
if not File.exists?(File.join(destination_dir, 'nanoc.yaml'))
puts "Destination directory does not appear to be a nanoc site."
exit 2
end
# list of files to copy
base_dir = File.expand_path(File.dirname(__FILE__))
files_to_copy = [
['commands', 'addlog.rb'],
['content', 'items', 'index.rhtml'],
['lib', 'helpers', 'ploggy.rb'],
['Rules']
]
# copy all files
files_to_copy.each{|rf|
src_f = File.join(base_dir, *rf)
dest_f = File.join(destination_dir, *rf)
if not FileUtils.identical?(src_f, dest_f)
FileUtils.cp(src_f, dest_f, {verbose: true})
end
}
# output a warning
rf = ['lib', 'helpers', 'ploggy_config.rb']
puts "Done. You possible need to manually merge or"
puts " cp " + File.join(base_dir, *rf) + " " + File.join(destination_dir, *rf) + "."
puts "This is not done automatically to prevent overwriting of your project configuration."