Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Replace deprecated File.exists? with exist? for Ruby script #263

Conversation

pocke
Copy link
Contributor

@pocke pocke commented Mar 14, 2022

This PR replaces File.exists? with exist? in the Ruby wrapper.

File.exists? has been deprecated for many years. And it will be removed since the next release of Ruby (Ruby 3.2).

It displays a warning on Ruby 3.1 with -w option.

$ env RUBYOPT=-w lefthook install
/Users/kuwabara.masataka/.rbenv/versions/3.1.1/lib/ruby/gems/3.1.0/gems/lefthook-0.7.7/bin/lefthook:30: warning: File.exists? is deprecated; use File.exist? instead
Added config:  /path/to/lefthook.yml

It fails on Ruby 3.2-dev.

$ lefthook install
/Users/kuwabara.masataka/.rbenv/versions/trunk/lib/ruby/gems/3.2.0+0/gems/lefthook-0.7.7/bin/lefthook:30:in `<top (required)>': undefined method `exists?' for File:Class (NoMethodError)

unless File.exists?(cmd)
           ^^^^^^^^
Did you mean?  exist?
	from /Users/kuwabara.masataka/.rbenv/versions/trunk/bin/lefthook:25:in `load'
	from /Users/kuwabara.masataka/.rbenv/versions/trunk/bin/lefthook:25:in `<main>'

@Envek Envek merged commit c3b9420 into evilmartians:master Mar 14, 2022
@Envek
Copy link
Member

Envek commented Mar 14, 2022

Nice! Thank you!

@pocke pocke deleted the Replace__File_exist___instead_of_deprecated__exists___for_Ruby_script branch March 14, 2022 12:02
mrexox added a commit that referenced this pull request Jun 9, 2022
* master:
  Account for GOAMD64 suffix in directory names in NPM and GEM packages [ci skip]
  Include version into RPM/DEB packages on release [ci skip]
  0.8.0: Skip hooks in merge/rebase, hide summary, NPM installer package
  Split NPM package to two: bundled and installer (#273)
  Include archived binaries in the releases (#189)
  docs: s/agrs/args (#265) [ci skip]
  chore(lint): Fix golangci-lint complains
  docs(usage): Add commitlint example in full_guide (#201)
  Fix unreachable conditional in hook template (#242)
  fix(hook.tmpl): adds cpu arch and os arch to `lefthook`'s filepath (#260)
  Replace deprecated `File.exists?` with `exist?` for Ruby wrapper (#263)
  Fix typo in docs/full_guide.md (#256)
  0.7.7: Fix arguments passing and various NPM-related fixes
  Fix incorrect npx command in git hook script template (#236)
  Update project URLs in NPM package.json (#235)
  Pass all arguments to downstream hooks (#231)
  Allows lefthook to work when node_modules is not in root folder for npx (#224)
  Do not initialize git config on `help` and `version` commands (#209)
  node: fix postinstall: process.cwd is a function and should be called

Signed-off-by: Valentin Kiselev <mrexox@evilmartians.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants