summaryrefslogtreecommitdiff
path: root/lib/leap_cli/util.rb
diff options
context:
space:
mode:
Diffstat (limited to 'lib/leap_cli/util.rb')
-rw-r--r--lib/leap_cli/util.rb20
1 files changed, 10 insertions, 10 deletions
diff --git a/lib/leap_cli/util.rb b/lib/leap_cli/util.rb
index 5014238..248a59c 100644
--- a/lib/leap_cli/util.rb
+++ b/lib/leap_cli/util.rb
@@ -38,7 +38,7 @@ module LeapCli
#
def bail!(*message)
if block_given?
- LeapCli.set_log_level(3)
+ LeapCli.logger.log_level = 3
yield
elsif message
log 0, *message
@@ -119,7 +119,7 @@ module LeapCli
base = options[:base] || Path.provider
file_list = files.collect { |file_path|
file_path = Path.named_path(file_path, base)
- File.exists?(file_path) ? Path.relative_path(file_path, base) : nil
+ File.exist?(file_path) ? Path.relative_path(file_path, base) : nil
}.compact
if file_list.length > 1
bail! do
@@ -138,7 +138,7 @@ module LeapCli
options = files.last.is_a?(Hash) ? files.pop : {}
file_list = files.collect { |file_path|
file_path = Path.named_path(file_path)
- !File.exists?(file_path) ? Path.relative_path(file_path) : nil
+ !File.exist?(file_path) ? Path.relative_path(file_path) : nil
}.compact
if file_list.length > 1
bail! do
@@ -157,7 +157,7 @@ module LeapCli
def file_exists?(*files)
files.each do |file_path|
file_path = Path.named_path(file_path)
- if !File.exists?(file_path)
+ if !File.exist?(file_path)
return false
end
end
@@ -233,7 +233,7 @@ module LeapCli
#
def replace_file!(filepath, &block)
filepath = Path.named_path(filepath)
- if !File.exists?(filepath)
+ if !File.exist?(filepath)
content = yield(nil)
unless content.nil?
write_file!(filepath, content)
@@ -258,7 +258,7 @@ module LeapCli
def remove_file!(filepath)
filepath = Path.named_path(filepath)
- if File.exists?(filepath)
+ if File.exist?(filepath)
if File.directory?(filepath)
remove_directory!(filepath)
else
@@ -298,7 +298,7 @@ module LeapCli
def write_file!(filepath, contents)
filepath = Path.named_path(filepath)
ensure_dir File.dirname(filepath)
- existed = File.exists?(filepath)
+ existed = File.exist?(filepath)
if existed
if file_content_equals?(filepath, contents)
log :nochange, filepath, 2
@@ -320,11 +320,11 @@ module LeapCli
def rename_file!(oldpath, newpath)
oldpath = Path.named_path(oldpath)
newpath = Path.named_path(newpath)
- if File.exists? newpath
+ if File.exist? newpath
log :skipping, "#{Path.relative_path(newpath)}, file already exists"
return
end
- if !File.exists? oldpath
+ if !File.exist? oldpath
log :skipping, "#{Path.relative_path(oldpath)}, file is missing"
return
end
@@ -429,7 +429,7 @@ module LeapCli
Dir.chdir(dir) do
branch = `git symbolic-ref HEAD 2>/dev/null`.strip
if branch.chars.any?
- branch.sub /^refs\/heads\//, ''
+ branch.sub(/^refs\/heads\//, '')
else
nil
end