Skip to content

Commit

Permalink
Replace deprecated {File,Dir}.exists? with {File,Dir}.exist?
Browse files Browse the repository at this point in the history
  • Loading branch information
NicholasBHubbard authored and jordansissel committed Feb 1, 2023
1 parent 3150610 commit d0c139a
Show file tree
Hide file tree
Showing 7 changed files with 20 additions and 20 deletions.
8 changes: 4 additions & 4 deletions lib/fpm/command.rb
Original file line number Diff line number Diff line change
Expand Up @@ -298,7 +298,7 @@ def execute
args << "."
end

if !File.exists?(workdir)
if !File.exist?(workdir)
logger.fatal("Given --workdir=#{workdir} is not a path that exists.")
raise FPM::Package::InvalidArgument, "The given workdir '#{workdir}' does not exist."
end
Expand Down Expand Up @@ -371,7 +371,7 @@ def execute

# If --inputs was specified, read it as a file.
if !inputs.nil?
if !File.exists?(inputs)
if !File.exist?(inputs)
logger.fatal("File given for --inputs does not exist (#{inputs})")
return 1
end
Expand All @@ -386,7 +386,7 @@ def execute
# If --exclude-file was specified, read it as a file and append to
# the exclude pattern list.
if !exclude_file.nil?
if !File.exists?(exclude_file)
if !File.exist?(exclude_file)
logger.fatal("File given for --exclude-file does not exist (#{exclude_file})")
return 1
end
Expand Down Expand Up @@ -451,7 +451,7 @@ def execute
# Skip scripts not set
next if path.nil?

if !File.exists?(path)
if !File.exist?(path)
logger.error("No such file (for #{scriptname.to_s}): #{path.inspect}")
script_errors << path
end
Expand Down
8 changes: 4 additions & 4 deletions lib/fpm/package/deb.rb
Original file line number Diff line number Diff line change
Expand Up @@ -591,7 +591,7 @@ def output(output_path)
end # No need to close, GzipWriter#close will close it.
end

if File.exists?(dest_changelog) and not File.exists?(dest_upstream_changelog)
if File.exist?(dest_changelog) and not File.exist?(dest_upstream_changelog)
# see https://www.debian.org/doc/debian-policy/ch-docs.html#s-changelogs
File.rename(dest_changelog, dest_upstream_changelog)
end
Expand Down Expand Up @@ -747,7 +747,7 @@ def converted_from(origin)

if origin == FPM::Package::Deb
changelog_path = staging_path("usr/share/doc/#{name}/changelog.Debian.gz")
if File.exists?(changelog_path)
if File.exist?(changelog_path)
logger.debug("Found a deb changelog file, using it.", :path => changelog_path)
attributes[:deb_changelog] = build_path("deb_changelog")
File.open(attributes[:deb_changelog], "w") do |deb_changelog|
Expand All @@ -761,7 +761,7 @@ def converted_from(origin)

if origin == FPM::Package::Deb
changelog_path = staging_path("usr/share/doc/#{name}/changelog.gz")
if File.exists?(changelog_path)
if File.exist?(changelog_path)
logger.debug("Found an upstream changelog file, using it.", :path => changelog_path)
attributes[:deb_upstream_changelog] = build_path("deb_upstream_changelog")
File.open(attributes[:deb_upstream_changelog], "w") do |deb_upstream_changelog|
Expand Down Expand Up @@ -1038,7 +1038,7 @@ def add_path(path, allconfigs)
etcfiles = []
# Add everything in /etc
begin
if !attributes[:deb_no_default_config_files?] && File.exists?(staging_path("/etc"))
if !attributes[:deb_no_default_config_files?] && File.exist?(staging_path("/etc"))
logger.warn("Debian packaging tools generally labels all files in /etc as config files, " \
"as mandated by policy, so fpm defaults to this behavior for deb packages. " \
"You can disable this default behavior with --deb-no-default-config-files flag")
Expand Down
2 changes: 1 addition & 1 deletion lib/fpm/package/dir.rb
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@ def input(path)
# This mapping should work the same way 'rsync -a' does
# Meaning 'rsync -a source dest'
# and 'source=dest' in fpm work the same as the above rsync
if path =~ /.=./ && !File.exists?(chdir == '.' ? path : File.join(chdir, path))
if path =~ /.=./ && !File.exist?(chdir == '.' ? path : File.join(chdir, path))
origin, destination = path.split("=", 2)

if File.directory?(origin) && origin[-1,1] == "/"
Expand Down
2 changes: 1 addition & 1 deletion lib/fpm/package/puppet.rb
Original file line number Diff line number Diff line change
Expand Up @@ -60,7 +60,7 @@ def build!(params)
end # case name
end # self.scripts.each

if File.exists?(params[:output])
if File.exist?(params[:output])
# TODO(sissel): Allow folks to choose output?
logger.error("Puppet module directory '#{params[:output]}' already " \
"exists. Delete it or choose another output (-p flag)")
Expand Down
2 changes: 1 addition & 1 deletion lib/fpm/util.rb
Original file line number Diff line number Diff line change
Expand Up @@ -345,7 +345,7 @@ def copy_entry(src, dst, preserve=false, remove_destination=false)
when 'characterSpecial', 'blockSpecial'
raise UnsupportedSpecialFile.new("File is device which fpm doesn't know how to copy (#{File.ftype(src)}): #{src}")
when 'directory'
FileUtils.mkdir(dst) unless File.exists? dst
FileUtils.mkdir(dst) unless File.exist? dst
else
# if the file with the same dev and inode has been copied already -
# hard link it's copy to `dst`, otherwise make an actual copy
Expand Down
2 changes: 1 addition & 1 deletion spec/fpm/package/tar_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@
end

it "doesn't include a .scripts folder" do
insist { Dir.exists?(File.join(output_dir, '.scripts')) } == false
insist { Dir.exist?(File.join(output_dir, '.scripts')) } == false
end

after do
Expand Down
16 changes: 8 additions & 8 deletions spec/fpm/package/virtualenv_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@ def virtualenv_usable?

activate_path = File.join(subject.build_path, '/usr/share/python/pip/bin/activate')

expect(File.exists?(activate_path)).to(be_truthy)
expect(File.exist?(activate_path)).to(be_truthy)
end

it "can override the version specified on the input" do
Expand Down Expand Up @@ -85,7 +85,7 @@ def virtualenv_usable?
subject.input("pip==8.1.2")

activate_path = File.join(subject.build_path, '/opt/foo/pip/bin/activate')
expect(File.exists?(activate_path)).to(be_truthy)
expect(File.exist?(activate_path)).to(be_truthy)
end
end

Expand All @@ -95,10 +95,10 @@ def virtualenv_usable?
subject.input("pip==8.1.2")

activate_path = File.join(subject.build_path, '/usr/share/python/pip/bin/activate')
expect(File.exists?(activate_path)).to(be_truthy)
expect(File.exist?(activate_path)).to(be_truthy)

egg_path = File.join(subject.build_path, '/setup.py')
expect(File.exists?(egg_path)).to(be_truthy)
expect(File.exist?(egg_path)).to(be_truthy)
end
end

Expand All @@ -118,7 +118,7 @@ def virtualenv_usable?
subject.input(File.join(fixtures_dir, 'requirements.txt'))

activate_path = File.join(subject.build_path, '/usr/share/python/virtualenv/bin/activate')
expect(File.exists?(activate_path)).to(be_truthy)
expect(File.exist?(activate_path)).to(be_truthy)
expect(subject.name).to eq("virtualenv-virtualenv")
end
end
Expand All @@ -129,7 +129,7 @@ def virtualenv_usable?
subject.input(File.join(fixtures_dir, 'requirements.txt'))
activate_path = File.join(subject.build_path, '/usr/share/python/virtualenv/bin/activate')

expect(File.exists?(activate_path)).to(be_truthy)
expect(File.exist?(activate_path)).to(be_truthy)

expect(subject.name).to eq("virtualenv-foo")
end
Expand All @@ -143,7 +143,7 @@ def virtualenv_usable?

activate_path = File.join(subject.staging_path, '/opt/foo/bin/activate')

expect(File.exists?(activate_path)).to(be_truthy)
expect(File.exist?(activate_path)).to(be_truthy)
end

it "takes precedence over other folder options" do
Expand All @@ -153,7 +153,7 @@ def virtualenv_usable?

activate_path = File.join(subject.staging_path, '/opt/foo/bin/activate')

expect(File.exists?(activate_path)).to(be_truthy)
expect(File.exist?(activate_path)).to(be_truthy)
end
end
end

0 comments on commit d0c139a

Please sign in to comment.