Merge pull request #893 from jasonwbarnett/jwb/fix-exists

This commit is contained in:
Luiz Gonzaga dos Santos Filho
2026-01-17 15:37:39 -08:00
committed by GitHub
4 changed files with 13 additions and 13 deletions

View File

@@ -101,7 +101,7 @@ task :install_vundle do
puts "" puts ""
vundle_path = File.join('vim','bundle', 'vundle') vundle_path = File.join('vim','bundle', 'vundle')
unless File.exists?(vundle_path) unless File.exist?(vundle_path)
run %{ run %{
cd $HOME/.yadr cd $HOME/.yadr
git clone https://github.com/gmarik/vundle.git #{vundle_path} git clone https://github.com/gmarik/vundle.git #{vundle_path}
@@ -197,7 +197,7 @@ def install_term_theme
run %{ /usr/libexec/PlistBuddy -c "Merge 'iTerm2/Solarized Dark.itermcolors' :'Custom Color Presets':'Solarized Dark'" ~/Library/Preferences/com.googlecode.iterm2.plist } run %{ /usr/libexec/PlistBuddy -c "Merge 'iTerm2/Solarized Dark.itermcolors' :'Custom Color Presets':'Solarized Dark'" ~/Library/Preferences/com.googlecode.iterm2.plist }
# If iTerm2 is not installed or has never run, we can't autoinstall the profile since the plist is not there # If iTerm2 is not installed or has never run, we can't autoinstall the profile since the plist is not there
if !File.exists?(File.join(ENV['HOME'], '/Library/Preferences/com.googlecode.iterm2.plist')) if !File.exist?(File.join(ENV['HOME'], '/Library/Preferences/com.googlecode.iterm2.plist'))
puts "======================================================" puts "======================================================"
puts "To make sure your profile is using the solarized theme" puts "To make sure your profile is using the solarized theme"
puts "Please check your settings under:" puts "Please check your settings under:"
@@ -279,7 +279,7 @@ def install_prezto
puts "Zsh is already configured as your shell of choice. Restart your session to load the new settings" puts "Zsh is already configured as your shell of choice. Restart your session to load the new settings"
else else
puts "Setting zsh as your default shell" puts "Setting zsh as your default shell"
if File.exists?("/usr/local/bin/zsh") if File.exist?("/usr/local/bin/zsh")
if File.readlines("/private/etc/shells").grep("/usr/local/bin/zsh").empty? if File.readlines("/private/etc/shells").grep("/usr/local/bin/zsh").empty?
puts "Adding zsh to standard shell list" puts "Adding zsh to standard shell list"
run %{ echo "/usr/local/bin/zsh" | sudo tee -a /private/etc/shells } run %{ echo "/usr/local/bin/zsh" | sudo tee -a /private/etc/shells }
@@ -310,7 +310,7 @@ def install_files(files, method = :symlink)
puts "Source: #{source}" puts "Source: #{source}"
puts "Target: #{target}" puts "Target: #{target}"
if File.exists?(target) && (!File.symlink?(target) || (File.symlink?(target) && File.readlink(target) != source)) if File.exist?(target) && (!File.symlink?(target) || (File.symlink?(target) && File.readlink(target) != source))
puts "[Overwriting] #{target}...leaving original at #{target}.backup..." puts "[Overwriting] #{target}...leaving original at #{target}.backup..."
run %{ mv "$HOME/.#{file}" "$HOME/.#{file}.backup" } run %{ mv "$HOME/.#{file}" "$HOME/.#{file}.backup" }
end end
@@ -327,7 +327,7 @@ def install_files(files, method = :symlink)
end end
def needs_migration_to_vundle? def needs_migration_to_vundle?
File.exists? File.join('vim', 'bundle', 'tpope-vim-pathogen') File.exist? File.join('vim', 'bundle', 'tpope-vim-pathogen')
end end

View File

@@ -18,8 +18,8 @@ optparse = OptionParser.new do|opts|
$options[:outfolder] = false $options[:outfolder] = false
opts.on( '-o DIR','--output DIR', 'Output folder, default STDOUT. Use "." for current folder, void if output type is "nv"' ) do |outfolder| opts.on( '-o DIR','--output DIR', 'Output folder, default STDOUT. Use "." for current folder, void if output type is "nv"' ) do |outfolder|
filepath = File.expand_path(outfolder) filepath = File.expand_path(outfolder)
unless File.exists?(filepath) && File.directory?(filepath) unless File.exist?(filepath) && File.directory?(filepath)
if File.exists?(filepath) if File.exist?(filepath)
puts "Output folder is not a directory" puts "Output folder is not a directory"
exit exit
else else
@@ -90,7 +90,7 @@ end
def html_file_to_markdown(outtype) def html_file_to_markdown(outtype)
$input.each {|file| $input.each {|file|
input = File.expand_path(file) input = File.expand_path(file)
if File.exists?(input) if File.exist?(input)
html = File.open(input,'r') {|infile| html = File.open(input,'r') {|infile|
CGI.escape(CGI.unescapeHTML(infile.read)) CGI.escape(CGI.unescapeHTML(infile.read))
} }
@@ -206,7 +206,7 @@ end
def bookmark_to_markdown(outtype) def bookmark_to_markdown(outtype)
$input.each {|f| $input.each {|f|
file = File.expand_path(f) file = File.expand_path(f)
if File.exists?(file) if File.exist?(file)
outfile = $options[:outfolder] ? $options[:outfolder] : "" outfile = $options[:outfolder] ? $options[:outfolder] : ""
outfile += %x{mdls -name 'kMDItemDisplayName' -raw "#{file}"}.strip.gsub(/(\.webbookmark|\.webloc)$/,'') + '.md' outfile += %x{mdls -name 'kMDItemDisplayName' -raw "#{file}"}.strip.gsub(/(\.webbookmark|\.webloc)$/,'') + '.md'
source_url = %x{mdls -name 'kMDItemURL' -raw "#{file}"}.strip source_url = %x{mdls -name 'kMDItemURL' -raw "#{file}"}.strip

View File

@@ -36,9 +36,9 @@ module Helpers
# available # available
def binary_filename_for(name) def binary_filename_for(name)
user_file = File.join(binary_directory, "#{basename}-#{name}") user_file = File.join(binary_directory, "#{basename}-#{name}")
return user_file if File.exists?(user_file) return user_file if File.exist?(user_file)
built_in = File.join(built_in_commands_directory, "#{name}.rb") built_in = File.join(built_in_commands_directory, "#{name}.rb")
return built_in if File.exists?(built_in) return built_in if File.exist?(built_in)
user_file user_file
end end

View File

@@ -32,12 +32,12 @@ module Vundle
private private
def self.contains_vundle?(vundle_name) def self.contains_vundle?(vundle_name)
FileUtils.touch(@vundles_path) unless File.exists? @vundles_path FileUtils.touch(@vundles_path) unless File.exist? @vundles_path
File.read(@vundles_path).include?(vundle_name) File.read(@vundles_path).include?(vundle_name)
end end
def self.vundles_from_file def self.vundles_from_file
FileUtils.touch(@vundles_path) unless File.exists? @vundles_path FileUtils.touch(@vundles_path) unless File.exist? @vundles_path
File.read(@vundles_path).split("\n") File.read(@vundles_path).split("\n")
end end