Skip to content

Commit 7135a63

Browse files
authored
Replace call deprecated to File.exists? with File.exist? (#218)
- File.exists? was removed in Ruby 3.2.x - Drop Ruby versions which are not supported by fpm anymore
1 parent 545b2fb commit 7135a63

File tree

6 files changed

+13
-13
lines changed

6 files changed

+13
-13
lines changed

.github/workflows/ruby.yml

+1-1
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@ jobs:
88
runs-on: ubuntu-latest
99
strategy:
1010
matrix:
11-
ruby: ["2.4", "2.5", "2.6", "2.7", "3.0", "3.1"]
11+
ruby: ["2.7", "3.0", "3.1", "3.2"]
1212

1313
steps:
1414
- uses: actions/checkout@v1

lib/fpm/cookery/chain_packager.rb

+2-2
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@ def install_build_deps
2020
DependencyInspector.verify!([], recipe.build_depends)
2121
recipe.chain_recipes.each do |name|
2222
recipe_file = build_recipe_file_path(name)
23-
unless File.exists?(recipe_file)
23+
unless File.exist?(recipe_file)
2424
error_message = "Cannot find a recipe for #{name} at #{recipe_file}"
2525
Log.fatal error_message
2626
raise Error::ExecutionFailure, error_message
@@ -49,7 +49,7 @@ def run
4949
recipe.chain_recipes.each do |name|
5050
recipe_file = build_recipe_file_path(name)
5151

52-
unless File.exists?(recipe_file)
52+
unless File.exist?(recipe_file)
5353
Log.fatal "Cannot find a recipe for #{name} at #{recipe_file}"
5454
exit 1
5555
end

lib/fpm/cookery/cli.rb

+2-2
Original file line numberDiff line numberDiff line change
@@ -60,15 +60,15 @@ def recipe_file
6060
file = File.expand_path(recipe)
6161

6262
# Allow giving the directory containing a recipe.rb
63-
if File.directory?(file) && File.exists?(File.join(file, 'recipe.rb'))
63+
if File.directory?(file) && File.exist?(File.join(file, 'recipe.rb'))
6464
file = File.join(file, 'recipe.rb')
6565
end
6666

6767
file
6868
end
6969

7070
def validate
71-
unless File.exists?(recipe_file)
71+
unless File.exist?(recipe_file)
7272
Log.error 'No recipe.rb found in the current directory, abort.'
7373
exit 1
7474
end

lib/fpm/cookery/omnibus_packager.rb

+1-1
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@ def load_omnibus_recipes(_recipe)
2121
_recipe.omnibus_recipes.each do |name|
2222
recipe_file = build_recipe_file_path(name)
2323
Log.info "Loading dependency recipe #{name} from #{recipe_file}"
24-
unless File.exists?(recipe_file)
24+
unless File.exist?(recipe_file)
2525
error_message = "Cannot find a recipe for #{name} at #{recipe_file}"
2626
Log.fatal error_message
2727
raise Error::ExecutionFailure, error_message

lib/fpm/cookery/packager.rb

+4-4
Original file line numberDiff line numberDiff line change
@@ -119,7 +119,7 @@ def dispense
119119

120120
# Do not extract source again because it might destroy changes
121121
# that have been made to the source. (like patches)
122-
if File.exists?(extract_cookie)
122+
if File.exist?(extract_cookie)
123123
extracted_source = File.read(extract_cookie).chomp
124124
Log.debug "Extract cookie exists, using existing source directory: #{extracted_source}"
125125
else
@@ -149,7 +149,7 @@ def dispense
149149

150150
build_cookie = build_cookie_name(package_name)
151151

152-
if File.exists?(build_cookie)
152+
if File.exist?(build_cookie)
153153
Log.warn "Skipping build of #{recipe.name} because build cookie found (#{build_cookie})," \
154154
" use \"fpm-cook clean\" to rebuild!"
155155
else
@@ -161,7 +161,7 @@ def dispense
161161
end
162162

163163
FileUtils.rm_rf(recipe.destdir) unless keep_destdir?
164-
recipe.destdir.mkdir unless File.exists?(recipe.destdir)
164+
recipe.destdir.mkdir unless File.exist?(recipe.destdir)
165165

166166
begin
167167
recipe.installing = true
@@ -243,7 +243,7 @@ def add_scripts(recipe, input)
243243
script_file = File.expand_path("../#{script_file.to_s}", recipe.filename)
244244
end
245245

246-
if File.exists?(script_file)
246+
if File.exist?(script_file)
247247
input.add_script(script, File.read(script_file.to_s))
248248
else
249249
Log.error "#{script} script '#{script_file}' is missing"

spec/path_spec.rb

+3-3
Original file line numberDiff line numberDiff line change
@@ -91,18 +91,18 @@
9191
it "creates the directory" do
9292
dir = Dir.mktmpdir
9393
FileUtils.rm_rf(dir)
94-
expect(File.exists?(dir)).to eq(false)
94+
expect(File.exist?(dir)).to eq(false)
9595

9696
FPM::Cookery::Path.new(dir).mkdir
97-
expect(File.exists?(dir)).to eq(true)
97+
expect(File.exist?(dir)).to eq(true)
9898

9999
FileUtils.rm_rf(dir)
100100
end
101101

102102
describe "directory exists" do
103103
it "does not throw an error" do
104104
dir = Dir.mktmpdir
105-
expect(File.exists?(dir)).to eq(true)
105+
expect(File.exist?(dir)).to eq(true)
106106

107107
expect(FPM::Cookery::Path.new(dir).mkdir).to eq([dir])
108108

0 commit comments

Comments
 (0)