Fix instances of deprecated class methods (#15183)

Replace ::File.exists? for ::File.exist?
This commit is contained in:
Andres Rodriguez 2023-07-17 11:32:46 -04:00 committed by GitHub
parent cb19d4e88a
commit 1d558c35d0
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
23 changed files with 48 additions and 43 deletions

View file

@ -20,6 +20,11 @@ AllCops:
DisplayCopNames: true DisplayCopNames: true
UseCache: false UseCache: false
#################### Lint ###########################
##### Enabled Cops #####
Lint/DeprecatedClassMethods:
Enabled: true
#################### Layout ########################### #################### Layout ###########################
##### Enabled Cops ##### ##### Enabled Cops #####
Layout/TrailingWhitespace: Layout/TrailingWhitespace:

View file

@ -113,14 +113,14 @@ module LogStash
require "fileutils" require "fileutils"
# create Gemfile from template iff it does not exist # create Gemfile from template iff it does not exist
unless ::File.exists?(Environment::GEMFILE_PATH) unless ::File.exist?(Environment::GEMFILE_PATH)
FileUtils.copy( FileUtils.copy(
::File.join(Environment::LOGSTASH_HOME, "Gemfile.template"), Environment::GEMFILE_PATH ::File.join(Environment::LOGSTASH_HOME, "Gemfile.template"), Environment::GEMFILE_PATH
) )
end end
# create Gemfile.jruby-1.9.lock from template iff a template exists it itself does not exist # create Gemfile.jruby-1.9.lock from template iff a template exists it itself does not exist
lock_template = ::File.join(ENV["LOGSTASH_HOME"], "Gemfile.jruby-3.1.lock.release") lock_template = ::File.join(ENV["LOGSTASH_HOME"], "Gemfile.jruby-3.1.lock.release")
if ::File.exists?(lock_template) && !::File.exists?(Environment::LOCKFILE) if ::File.exist?(lock_template) && !::File.exist?(Environment::LOCKFILE)
FileUtils.copy(lock_template, Environment::LOCKFILE) FileUtils.copy(lock_template, Environment::LOCKFILE)
end end

View file

@ -54,7 +54,7 @@ module LogStash
def oss_only? def oss_only?
return true if ENV['OSS']=="true" return true if ENV['OSS']=="true"
!File.exists?(File.join(LogStash::Environment::LOGSTASH_HOME, "x-pack")) !File.exist?(File.join(LogStash::Environment::LOGSTASH_HOME, "x-pack"))
end end
def win_platform? def win_platform?

View file

@ -63,7 +63,7 @@ class LogStash::PluginManager::Generate < LogStash::PluginManager::Command
target_entry = File.join(target, entry) target_entry = File.join(target, entry)
if File.directory?(source_entry) if File.directory?(source_entry)
FileUtils.mkdir(target_entry) unless File.exists?(target_entry) FileUtils.mkdir(target_entry) unless File.exist?(target_entry)
transform_r(source_entry, target_entry) transform_r(source_entry, target_entry)
else else
# copy the new file, in case of being an .erb file should render first # copy the new file, in case of being an .erb file should render first

View file

@ -45,7 +45,7 @@ class LogStash::PluginManager::PrepareOfflinePack < LogStash::PluginManager::Com
signal_error("Package creation cancelled: You must specify the zip extension for the provided filename: #{output}.") signal_error("Package creation cancelled: You must specify the zip extension for the provided filename: #{output}.")
end end
if ::File.exists?(output) if ::File.exist?(output)
if overwrite? if overwrite?
File.delete(output) File.delete(output)
else else

View file

@ -240,7 +240,7 @@ class LogStash::Agent
return @id if @id return @id if @id
uuid = nil uuid = nil
if ::File.exists?(id_path) if ::File.exist?(id_path)
begin begin
uuid = ::File.open(id_path) {|f| f.each_line.first.chomp } uuid = ::File.open(id_path) {|f| f.each_line.first.chomp }
rescue => e rescue => e

View file

@ -566,7 +566,7 @@ module LogStash::Config::Mixin
#return false, "Require absolute path, got relative path #{value.first}?" #return false, "Require absolute path, got relative path #{value.first}?"
#end #end
if !File.exists?(value.first) # Check if the file exists if !File.exist?(value.first) # Check if the file exists
return false, "File does not exist or cannot be opened #{value.first}" return false, "File does not exist or cannot be opened #{value.first}"
end end

View file

@ -22,7 +22,7 @@ $DEBUGLIST = (ENV["DEBUG"] || "").split(",")
require 'pathname' require 'pathname'
LogStash::ROOT = Pathname.new(File.join(File.expand_path(File.dirname(__FILE__)), "..", "..", "..")).cleanpath.to_s LogStash::ROOT = Pathname.new(File.join(File.expand_path(File.dirname(__FILE__)), "..", "..", "..")).cleanpath.to_s
LogStash::XPACK_PATH = File.join(LogStash::ROOT, "x-pack") LogStash::XPACK_PATH = File.join(LogStash::ROOT, "x-pack")
LogStash::OSS = ENV["OSS"] == "true" || !File.exists?(LogStash::XPACK_PATH) LogStash::OSS = ENV["OSS"] == "true" || !File.exist?(LogStash::XPACK_PATH)
if !LogStash::OSS if !LogStash::OSS
xpack_dir = File.join(LogStash::XPACK_PATH, "lib") xpack_dir = File.join(LogStash::XPACK_PATH, "lib")

View file

@ -614,7 +614,7 @@ module LogStash
class ExistingFilePath < Setting class ExistingFilePath < Setting
def initialize(name, default=nil, strict=true) def initialize(name, default=nil, strict=true)
super(name, ::String, default, strict) do |file_path| super(name, ::String, default, strict) do |file_path|
if !::File.exists?(file_path) if !::File.exist?(file_path)
raise ::ArgumentError.new("File \"#{file_path}\" must exist but was not found.") raise ::ArgumentError.new("File \"#{file_path}\" must exist but was not found.")
else else
true true

View file

@ -457,7 +457,7 @@ describe LogStash::Agent do
# wait for file existence otherwise it will raise exception on Windows # wait for file existence otherwise it will raise exception on Windows
wait(timeout) wait(timeout)
.for { ::File.exists?(new_config_output) && !::File.read(new_config_output).chomp.empty? } .for { ::File.exist?(new_config_output) && !::File.read(new_config_output).chomp.empty? }
.to eq(true) .to eq(true)
# ensure the converge_state_and_update method has updated metrics by # ensure the converge_state_and_update method has updated metrics by
# invoking the mutex # invoking the mutex

View file

@ -31,7 +31,7 @@ class Service
def setup def setup
puts "Setting up #{@name} service" puts "Setting up #{@name} service"
if File.exists?(@setup_script) if File.exist?(@setup_script)
`#{Shellwords.escape(@setup_script)}` `#{Shellwords.escape(@setup_script)}`
raise "#{@setup_script} FAILED with exit status #{$?}" unless $?.success? raise "#{@setup_script} FAILED with exit status #{$?}" unless $?.success?
else else
@ -42,7 +42,7 @@ class Service
def teardown def teardown
puts "Tearing down #{@name} service" puts "Tearing down #{@name} service"
if File.exists?(@teardown_script) if File.exist?(@teardown_script)
`#{Shellwords.escape(@teardown_script)}` `#{Shellwords.escape(@teardown_script)}`
raise "#{@teardown_script} FAILED with exit status #{$?}" unless $?.success? raise "#{@teardown_script} FAILED with exit status #{$?}" unless $?.success?
else else

View file

@ -60,7 +60,7 @@ describe "Test Logstash Pipeline id" do
wait_logstash_process_terminate wait_logstash_process_terminate
deprecation_log_file = "#{temp_dir}/logstash-deprecation.log" deprecation_log_file = "#{temp_dir}/logstash-deprecation.log"
expect(File.exists?(deprecation_log_file)).to be true expect(File.exist?(deprecation_log_file)).to be true
deprecation_log_content = IO.read(deprecation_log_file) deprecation_log_content = IO.read(deprecation_log_file)
expect(deprecation_log_content =~ /\[deprecation.logstash.filters.ruby\].*Teleport/).to be > 0 expect(deprecation_log_content =~ /\[deprecation.logstash.filters.ruby\].*Teleport/).to be > 0
end end

View file

@ -55,7 +55,7 @@ describe "Test Logstash configuration" do
send_data(test_tcp_port, sample_data) send_data(test_tcp_port, sample_data)
output_file = File.join(test_path, "logstash_env_test.log") output_file = File.join(test_path, "logstash_env_test.log")
try(num_retries) do try(num_retries) do
expect(File.exists?(output_file)).to be true expect(File.exist?(output_file)).to be true
end end
# should have created the file using env variable with filters adding a tag based on env variable # should have created the file using env variable with filters adding a tag based on env variable
try(num_retries) do try(num_retries) do

View file

@ -52,7 +52,7 @@ describe "uncaught exception" do
expect(@logstash.exit_code).to be 120 expect(@logstash.exit_code).to be 120
log_file = "#{logs_dir}/logstash-plain.log" log_file = "#{logs_dir}/logstash-plain.log"
expect( File.exists?(log_file) ).to be true expect( File.exist?(log_file) ).to be true
expect( File.read(log_file) ).to match /\[FATAL\]\[org.logstash.Logstash.*?java.lang.AssertionError: a fatal error/m expect( File.read(log_file) ).to match /\[FATAL\]\[org.logstash.Logstash.*?java.lang.AssertionError: a fatal error/m
end end
@ -65,7 +65,7 @@ describe "uncaught exception" do
expect(@logstash.exit_code).to be 0 # normal exit expect(@logstash.exit_code).to be 0 # normal exit
log_file = "#{logs_dir}/logstash-plain.log" log_file = "#{logs_dir}/logstash-plain.log"
expect( File.exists?(log_file) ).to be true expect( File.exist?(log_file) ).to be true
expect( File.read(log_file) ).to match /\[ERROR\]\[org.logstash.Logstash.*?uncaught exception \(in thread .*?java.io.EOFException: unexpected/m expect( File.read(log_file) ).to match /\[ERROR\]\[org.logstash.Logstash.*?uncaught exception \(in thread .*?java.io.EOFException: unexpected/m
end end

View file

@ -48,7 +48,7 @@ describe "Test Kafka Input" do
end end
after do after do
File.delete(file_output_path) if File.exists?(file_output_path) File.delete(file_output_path) if File.exist?(file_output_path)
end end
it "can ingest 37 apache log lines from Kafka broker" do it "can ingest 37 apache log lines from Kafka broker" do

View file

@ -68,7 +68,7 @@ describe "Ruby codec when used in" do
logstash_service.teardown logstash_service.teardown
plainlog_file = "#{temp_dir}/logstash-plain.log" plainlog_file = "#{temp_dir}/logstash-plain.log"
expect(File.exists?(plainlog_file)).to be true expect(File.exist?(plainlog_file)).to be true
logs = IO.read(plainlog_file) logs = IO.read(plainlog_file)
expect(logs).to_not include("ERROR") expect(logs).to_not include("ERROR")
@ -92,7 +92,7 @@ describe "Ruby codec when used in" do
logstash_service.teardown logstash_service.teardown
plainlog_file = "#{temp_dir}/logstash-plain.log" plainlog_file = "#{temp_dir}/logstash-plain.log"
expect(File.exists?(plainlog_file)).to be true expect(File.exist?(plainlog_file)).to be true
logs = IO.read(plainlog_file) logs = IO.read(plainlog_file)
expect(logs).to_not include("ERROR") expect(logs).to_not include("ERROR")
@ -112,7 +112,7 @@ describe "Ruby codec when used in" do
logstash_service.teardown logstash_service.teardown
plainlog_file = "#{temp_dir}/logstash-plain.log" plainlog_file = "#{temp_dir}/logstash-plain.log"
expect(File.exists?(plainlog_file)).to be true expect(File.exist?(plainlog_file)).to be true
logs = IO.read(plainlog_file) logs = IO.read(plainlog_file)
expect(logs).to_not include("ERROR") expect(logs).to_not include("ERROR")
end end

View file

@ -59,7 +59,7 @@ describe "Test Logstash Pipeline id" do
@ls.spawn_logstash("-w", "1" , "-e", config) @ls.spawn_logstash("-w", "1" , "-e", config)
wait_logstash_process_terminate(@ls) wait_logstash_process_terminate(@ls)
plainlog_file = "#{temp_dir}/logstash-plain.log" plainlog_file = "#{temp_dir}/logstash-plain.log"
expect(File.exists?(plainlog_file)).to be true expect(File.exist?(plainlog_file)).to be true
expect(IO.read(plainlog_file) =~ /\[logstash.javapipeline\s*\]\[#{pipeline_name}\]/).to be > 0 expect(IO.read(plainlog_file) =~ /\[logstash.javapipeline\s*\]\[#{pipeline_name}\]/).to be > 0
end end
@ -73,7 +73,7 @@ describe "Test Logstash Pipeline id" do
@ls.spawn_logstash("-w", "1" , "-e", config) @ls.spawn_logstash("-w", "1" , "-e", config)
wait_logstash_process_terminate(@ls) wait_logstash_process_terminate(@ls)
plainlog_file = "#{temp_dir}/logstash-plain.log" plainlog_file = "#{temp_dir}/logstash-plain.log"
expect(File.exists?(plainlog_file)).to be true expect(File.exist?(plainlog_file)).to be true
expect(IO.read(plainlog_file) =~ /Starting pipeline.*"pipeline.sources"=>\["config string"\]/).to be > 0 expect(IO.read(plainlog_file) =~ /Starting pipeline.*"pipeline.sources"=>\["config string"\]/).to be > 0
end end
@ -87,7 +87,7 @@ describe "Test Logstash Pipeline id" do
@ls.spawn_logstash("-w", "1", "-f", "#{initial_config_file}") @ls.spawn_logstash("-w", "1", "-f", "#{initial_config_file}")
wait_logstash_process_terminate(@ls) wait_logstash_process_terminate(@ls)
plainlog_file = "#{temp_dir}/logstash-plain.log" plainlog_file = "#{temp_dir}/logstash-plain.log"
expect(File.exists?(plainlog_file)).to be true expect(File.exist?(plainlog_file)).to be true
expect(IO.read(plainlog_file) =~ /Starting pipeline.*"pipeline.sources"=>\["#{initial_config_file}"\]/).to be > 0 expect(IO.read(plainlog_file) =~ /Starting pipeline.*"pipeline.sources"=>\["#{initial_config_file}"\]/).to be > 0
end end
@ -103,12 +103,12 @@ describe "Test Logstash Pipeline id" do
wait_logstash_process_terminate(@ls) wait_logstash_process_terminate(@ls)
pipeline_log_file = "#{temp_dir}/pipeline_#{pipeline_name}.log" pipeline_log_file = "#{temp_dir}/pipeline_#{pipeline_name}.log"
expect(File.exists?(pipeline_log_file)).to be true expect(File.exist?(pipeline_log_file)).to be true
content = IO.read(pipeline_log_file) content = IO.read(pipeline_log_file)
expect(content =~ /Pipeline started {"pipeline.id"=>"#{pipeline_name}"}/).to be > 0 expect(content =~ /Pipeline started {"pipeline.id"=>"#{pipeline_name}"}/).to be > 0
plainlog_file = "#{temp_dir}/logstash-plain.log" plainlog_file = "#{temp_dir}/logstash-plain.log"
expect(File.exists?(plainlog_file)).to be true expect(File.exist?(plainlog_file)).to be true
plainlog_content = IO.read(plainlog_file) plainlog_content = IO.read(plainlog_file)
expect(plainlog_content =~ /Pipeline started {"pipeline.id"=>"#{pipeline_name}"}/).to be_nil expect(plainlog_content =~ /Pipeline started {"pipeline.id"=>"#{pipeline_name}"}/).to be_nil
end end
@ -177,10 +177,10 @@ describe "Test Logstash Pipeline id" do
wait_logstash_process_terminate(@ls) wait_logstash_process_terminate(@ls)
pipeline_log_file = "#{temp_dir}/pipeline_#{pipeline_name}.log" pipeline_log_file = "#{temp_dir}/pipeline_#{pipeline_name}.log"
expect(File.exists?(pipeline_log_file)).to be false expect(File.exist?(pipeline_log_file)).to be false
plainlog_file = "#{temp_dir}/logstash-plain.log" plainlog_file = "#{temp_dir}/logstash-plain.log"
expect(File.exists?(plainlog_file)).to be true expect(File.exist?(plainlog_file)).to be true
plaing_log_content = IO.read(plainlog_file) plaing_log_content = IO.read(plainlog_file)
expect(plaing_log_content =~ /Pipeline started {"pipeline.id"=>"#{pipeline_name}"}/).to be > 0 expect(plaing_log_content =~ /Pipeline started {"pipeline.id"=>"#{pipeline_name}"}/).to be > 0
end end

View file

@ -56,7 +56,7 @@ describe "Test Logstash Pipeline id" do
@ls.spawn_logstash("-w", "1" , "-e", config) @ls.spawn_logstash("-w", "1" , "-e", config)
wait_logstash_process_terminate() wait_logstash_process_terminate()
plainlog_file = "#{temp_dir}/logstash-plain.log" plainlog_file = "#{temp_dir}/logstash-plain.log"
expect(File.exists?(plainlog_file)).to be true expect(File.exist?(plainlog_file)).to be true
#We know taht sleep plugin log debug lines #We know taht sleep plugin log debug lines
expect(IO.read(plainlog_file) =~ /\[sleep_filter_123\] Sleeping {:delay=>1}/).to be > 0 expect(IO.read(plainlog_file) =~ /\[sleep_filter_123\] Sleeping {:delay=>1}/).to be > 0
end end

View file

@ -34,7 +34,7 @@ describe "Test Logstash instance whose default settings are overridden" do
} }
before(:each) { before(:each) {
FileUtils.rm(@logstash_default_logs) if File.exists?(@logstash_default_logs) FileUtils.rm(@logstash_default_logs) if File.exist?(@logstash_default_logs)
# backup the application settings file -- logstash.yml # backup the application settings file -- logstash.yml
FileUtils.cp(@logstash_service.application_settings_file, "#{@logstash_service.application_settings_file}.original") FileUtils.cp(@logstash_service.application_settings_file, "#{@logstash_service.application_settings_file}.original")
} }
@ -78,14 +78,14 @@ describe "Test Logstash instance whose default settings are overridden" do
try(num_retries) do try(num_retries) do
expect(is_port_open?(test_port)).to be true expect(is_port_open?(test_port)).to be true
end end
expect(File.exists?("#{temp_dir}/logstash-plain.log")).to be true expect(File.exist?("#{temp_dir}/logstash-plain.log")).to be true
end end
it "should read config from the specified dir in logstash.yml" do it "should read config from the specified dir in logstash.yml" do
change_setting("path.config", temp_dir) change_setting("path.config", temp_dir)
test_config_path = File.join(temp_dir, "test.config") test_config_path = File.join(temp_dir, "test.config")
IO.write(test_config_path, tcp_config) IO.write(test_config_path, tcp_config)
expect(File.exists?(test_config_path)).to be true expect(File.exist?(test_config_path)).to be true
@logstash_service.spawn_logstash @logstash_service.spawn_logstash
@logstash_service.wait_for_logstash @logstash_service.wait_for_logstash
# check LS is up and running with new data path # check LS is up and running with new data path
@ -97,7 +97,7 @@ describe "Test Logstash instance whose default settings are overridden" do
it "should exit when config test_and_exit is set" do it "should exit when config test_and_exit is set" do
test_config_path = File.join(temp_dir, "test.config") test_config_path = File.join(temp_dir, "test.config")
IO.write(test_config_path, "#{tcp_config}") IO.write(test_config_path, "#{tcp_config}")
expect(File.exists?(test_config_path)).to be true expect(File.exist?(test_config_path)).to be true
s = {} s = {}
s["path.config"] = test_config_path s["path.config"] = test_config_path
s["config.test_and_exit"] = true s["config.test_and_exit"] = true
@ -111,7 +111,7 @@ describe "Test Logstash instance whose default settings are overridden" do
# now with bad config # now with bad config
IO.write(test_config_path, "#{tcp_config} filters {} ") IO.write(test_config_path, "#{tcp_config} filters {} ")
expect(File.exists?(test_config_path)).to be true expect(File.exist?(test_config_path)).to be true
@logstash_service.spawn_logstash @logstash_service.spawn_logstash
try(num_retries) do try(num_retries) do
expect(@logstash_service.exited?).to be true expect(@logstash_service.exited?).to be true
@ -151,7 +151,7 @@ describe "Test Logstash instance whose default settings are overridden" do
expect(is_port_open?(test_port)).to be true expect(is_port_open?(test_port)).to be true
end end
expect(File.exists?(@logstash_default_logs)).to be true expect(File.exist?(@logstash_default_logs)).to be true
resp = Manticore.get("http://localhost:#{http_port}/_node").body resp = Manticore.get("http://localhost:#{http_port}/_node").body
node_info = JSON.parse(resp) node_info = JSON.parse(resp)
@ -176,6 +176,6 @@ describe "Test Logstash instance whose default settings are overridden" do
expect(node_info["http_address"]).to eq("127.0.0.1:#{http_port}") expect(node_info["http_address"]).to eq("127.0.0.1:#{http_port}")
# make sure we log to console and not to any file # make sure we log to console and not to any file
expect(File.exists?(@logstash_default_logs)).to be false expect(File.exist?(@logstash_default_logs)).to be false
end end
end end

View file

@ -57,7 +57,7 @@ describe "Test Logstash Slowlog" do
@ls.wait_for_logstash @ls.wait_for_logstash
sleep 2 until @ls.exited? sleep 2 until @ls.exited?
slowlog_file = "#{temp_dir}/logstash-slowlog-plain.log" slowlog_file = "#{temp_dir}/logstash-slowlog-plain.log"
expect(File.exists?(slowlog_file)).to be true expect(File.exist?(slowlog_file)).to be true
expect(IO.read(slowlog_file).split("\n").size).to be >= 1 expect(IO.read(slowlog_file).split("\n").size).to be >= 1
end end
end end

View file

@ -476,7 +476,7 @@ namespace "artifact" do
end end
source_license_path = "licenses/#{license}.txt" source_license_path = "licenses/#{license}.txt"
fail("Missing source license: #{source_license_path}") unless File.exists?(source_license_path) fail("Missing source license: #{source_license_path}") unless File.exist?(source_license_path)
write_to_tar(tar, source_license_path, "logstash-#{LOGSTASH_VERSION}#{PACKAGE_SUFFIX}/LICENSE.txt") write_to_tar(tar, source_license_path, "logstash-#{LOGSTASH_VERSION}#{PACKAGE_SUFFIX}/LICENSE.txt")
# add build.rb to tar # add build.rb to tar
@ -513,7 +513,7 @@ namespace "artifact" do
ensure_logstash_version_constant_defined ensure_logstash_version_constant_defined
zippath = "build/logstash#{zip_suffix}-#{LOGSTASH_VERSION}#{PACKAGE_SUFFIX}#{platform}.zip" zippath = "build/logstash#{zip_suffix}-#{LOGSTASH_VERSION}#{PACKAGE_SUFFIX}#{platform}.zip"
puts("[artifact:zip] building #{zippath}") puts("[artifact:zip] building #{zippath}")
File.unlink(zippath) if File.exists?(zippath) File.unlink(zippath) if File.exist?(zippath)
Zip::File.open(zippath, Zip::File::CREATE) do |zipfile| Zip::File.open(zippath, Zip::File::CREATE) do |zipfile|
files(exclude_paths).each do |path| files(exclude_paths).each do |path|
path_in_zip = "logstash-#{LOGSTASH_VERSION}#{PACKAGE_SUFFIX}/#{path}" path_in_zip = "logstash-#{LOGSTASH_VERSION}#{PACKAGE_SUFFIX}/#{path}"
@ -521,7 +521,7 @@ namespace "artifact" do
end end
source_license_path = "licenses/#{license}.txt" source_license_path = "licenses/#{license}.txt"
fail("Missing source license: #{source_license_path}") unless File.exists?(source_license_path) fail("Missing source license: #{source_license_path}") unless File.exist?(source_license_path)
zipfile.add("logstash-#{LOGSTASH_VERSION}#{PACKAGE_SUFFIX}/LICENSE.txt", source_license_path) zipfile.add("logstash-#{LOGSTASH_VERSION}#{PACKAGE_SUFFIX}/LICENSE.txt", source_license_path)
# add build.rb to zip # add build.rb to zip
@ -677,7 +677,7 @@ namespace "artifact" do
script = "#{stage}-#{action}" # like, "before-install" script = "#{stage}-#{action}" # like, "before-install"
script_sym = script.gsub("-", "_").to_sym script_sym = script.gsub("-", "_").to_sym
script_path = File.join(File.dirname(__FILE__), "..", "pkg", platform, "#{script}.sh") script_path = File.join(File.dirname(__FILE__), "..", "pkg", platform, "#{script}.sh")
next unless File.exists?(script_path) next unless File.exist?(script_path)
out.scripts[script_sym] = File.read(script_path) out.scripts[script_sym] = File.read(script_path)
end end

View file

@ -17,7 +17,7 @@
namespace "vendor" do namespace "vendor" do
task "jruby" do |task, args| task "jruby" do |task, args|
system('./gradlew bootstrap') unless File.exists?(File.join("vendor", "jruby")) system('./gradlew bootstrap') unless File.exist?(File.join("vendor", "jruby"))
end # jruby end # jruby
namespace "force" do namespace "force" do
@ -27,7 +27,7 @@ namespace "vendor" do
task "gems", [:bundle] do |task, args| task "gems", [:bundle] do |task, args|
require "bootstrap/environment" require "bootstrap/environment"
if File.exists?(LogStash::Environment::LOCKFILE) # gradlew already bootstrap-ed if File.exist?(LogStash::Environment::LOCKFILE) # gradlew already bootstrap-ed
puts("Skipping bundler install...") puts("Skipping bundler install...")
else else
puts("Invoking bundler install...") puts("Invoking bundler install...")

View file

@ -12,7 +12,7 @@ require "time"
VERSIONS_YML_PATH = File.join(File.dirname(__FILE__), "..", "..", "..", "..", "versions.yml") VERSIONS_YML_PATH = File.join(File.dirname(__FILE__), "..", "..", "..", "..", "versions.yml")
VERSION_PATH = File.join(File.dirname(__FILE__), "..", "..", "..", "VERSION") VERSION_PATH = File.join(File.dirname(__FILE__), "..", "..", "..", "VERSION")
VERSION = File.exists?(VERSIONS_YML_PATH) ? YAML.load_file(VERSIONS_YML_PATH)['logstash'] : File.read(VERSION_PATH).strip VERSION = File.exist?(VERSIONS_YML_PATH) ? YAML.load_file(VERSIONS_YML_PATH)['logstash'] : File.read(VERSION_PATH).strip
def get_logstash_path def get_logstash_path
ENV["LOGSTASH_PATH"] || File.join(File.dirname(__FILE__), "../../../../") ENV["LOGSTASH_PATH"] || File.join(File.dirname(__FILE__), "../../../../")