Method: R10K::Module::Base#delete_spec_dir

Defined in:
lib/r10k/module/base.rb

#delete_spec_dirObject

Actually remove the spec dir



93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
# File 'lib/r10k/module/base.rb', line 93

def delete_spec_dir
  spec_path = @path + 'spec'
  if spec_path.symlink?
    spec_path = spec_path.realpath
  end
  if spec_path.directory?
    logger.debug2 _("Deleting spec data at #{spec_path}")
    # Use the secure flag for the #rm_rf method to avoid security issues
    # involving TOCTTOU(time of check to time of use); more details here:
    # https://ruby-doc.org/stdlib-2.7.0/libdoc/fileutils/rdoc/FileUtils.html#method-c-rm_rf
    # Additionally, #rm_rf also has problems in windows with with symlink targets
    # also being deleted; this should be revisted if Windows becomes higher priority.
    FileUtils.rm_rf(spec_path, secure: true)
  else
    logger.debug2 _("No spec dir detected at #{spec_path}, skipping deletion")
  end
end