5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
|
# File 'lib/commands/sync.rb', line 5
def run()
ARGV.reject { |x| x.start_with?("-") }
project_name = ARGV.shift || $settings.project_name
raise "No project name specified. Ensure you're in the project's directory or set it specifically. Run `enzyme help sync` for help." unless project_name
raise "The #{project_name} project could not be found." unless File.exist?("#{$settings.projects_directory}/#{project_name}")
raise "The `sync.share_name` setting is not set. Set it using `enzyme config sync.share_name \"Share Name\" --global`." unless $settings.sync.share_name
raise "The `sync.host` setting is not set. Set it using `enzyme config sync.host \"Host._afpovertcp._tcp.local\" --global`." unless $settings.sync.host
raise "The `sync.projects_directory` setting is not set. Set it using `enzyme config sync.projects_directory \"My Projects Directory\" --global`." unless $settings.sync.projects_directory
raise "The `user` setting is not set. Set it using `enzyme config user \"my_directory\" --global`." unless $settings.user
raise "The `sync.shared_directory` setting is not set. Set it using `enzyme config sync.shared_directory \"our_shared_directory\" --global`." unless $settings.sync.shared_directory
system "mkdir \"/Volumes/#{$settings.sync.share_name}\""
system "mount -t afp \"afp://#{$settings.sync.host}/#{$settings.sync.share_name}\" \"/Volumes/#{$settings.sync.share_name}\""
system "mkdir \"/Volumes/#{$settings.sync.share_name}/#{$settings.sync.projects_directory}/#{project_name}\""
system "rsync -aH --stats -v -u --progress --exclude '#{$settings.user}/**' \"/Volumes/#{$settings.sync.share_name}/#{$settings.sync.projects_directory}/#{project_name}/\" '#{$settings.projects_directory}/#{project_name}/resources/'"
system "rsync -aH --stats -v -u --progress --include '*/' --include '#{$settings.sync.shared_directory}/**' --include '#{$settings.user}/**' --exclude '*' '#{$settings.projects_directory}/#{project_name}/resources/' \"/Volumes/#{$settings.sync.share_name}/#{$settings.sync.projects_directory}/#{project_name}/\""
end
|