diff options
Diffstat (limited to 'lib/leap_cli/util.rb')
-rw-r--r-- | lib/leap_cli/util.rb | 12 |
1 files changed, 12 insertions, 0 deletions
diff --git a/lib/leap_cli/util.rb b/lib/leap_cli/util.rb index 6b62be5..9b04894 100644 --- a/lib/leap_cli/util.rb +++ b/lib/leap_cli/util.rb @@ -1,5 +1,6 @@ require 'digest/md5' require 'paint' +require 'fileutils' module LeapCli @@ -197,6 +198,17 @@ module LeapCli end end + def remove_directory!(filepath) + filepath = Path.named_path(filepath) + if filepath !~ /^#{Regexp.escape(Path.provider)}/ || filepath =~ /\.\./ + raise "sanity check on rm -r did not pass for #{filepath}" + end + if File.directory?(filepath) + FileUtils.rm_r(filepath) + log :removed, filepath + end + end + def write_file!(filepath, contents) filepath = Path.named_path(filepath) ensure_dir File.dirname(filepath) |