Module: VMC::Cli::FileHelper

Included in:
Command::Apps
Defined in:
lib/cli/file_helper.rb

Defined Under Namespace

Classes: SYSIgnore

Instance Method Summary collapse

Instance Method Details



91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
# File 'lib/cli/file_helper.rb', line 91

def check_unreachable_links(path,files)
  pwd = Pathname.new(path)
  abspath = pwd.realpath.to_s
  unreachable = []
  files.each do |f|
    file = Pathname.new(f)
    if file.symlink? && !file.realpath.to_s.start_with?(abspath)
      unreachable << file.relative_path_from(pwd).to_s
    end
  end

  unless unreachable.empty?
    root = pwd.relative_path_from(pwd).to_s
    err "Can't deploy application containing links '#{unreachable.join(",")}' that reach outside its root '#{root}'"
  end
end

#copy_files(project_root, files, dest_dir) ⇒ Object



108
109
110
111
112
113
114
115
116
117
118
119
120
# File 'lib/cli/file_helper.rb', line 108

def copy_files(project_root,files,dest_dir)
  project_root = Pathname.new(project_root)
  files.each do |f|
    dest = Pathname.new(f).relative_path_from(project_root)
    if File.symlink?(f)
      FileUtils.copy_entry(f,"#{dest_dir}/#{dest}")
    elsif File.directory?(f)
      FileUtils.mkdir_p("#{dest_dir}/#{dest}")
    else
      FileUtils.cp(f,"#{dest_dir}/#{dest}")
    end
  end      
end

#ignore_sockets(files) ⇒ Object



87
88
89
# File 'lib/cli/file_helper.rb', line 87

def ignore_sockets(files)
  files.reject { |f| File.socket? f }
end