Sha256: 83c1bac25076d772ecb85bb9c4f8ead3b4075e6f25a459d921be23d6bdd0776f
Contents?: true
Size: 821 Bytes
Versions: 30
Compression:
Stored size: 821 Bytes
Contents
# frozen_string_literal: true module TTY # Additional app-bundle-specific routines for TTY::Which module Which def app_bundle(cmd) app = cmd.sub(/(\.app)?$/, '.app') command = cmd.dup command.sub!(/\.app$/, '') app_dirs = %w[/Applications /Applications/Setapp ~/Applications] return command if ::File.exist?(app) return command if app_dirs.any? { |dir| ::File.exist?(::File.join(dir, app)) } false end module_function :app_bundle def bundle_id?(id) id =~ /^\w+(\.\w+){2,}/ ? true : false end module_function :bundle_id? def app?(cmd) if file_with_path?(cmd) return cmd if app_bundle(cmd) else app = app_bundle(cmd) return app if app end false end module_function :app? end end
Version data entries
30 entries across 30 versions & 1 rubygems