Skip to content

Commit 143a998

Browse files
mobilesfinksqingling128
authored andcommitted
Fix file permissions instead of just checking them. (#35)
1 parent 368235d commit 143a998

File tree

1 file changed

+17
-7
lines changed

1 file changed

+17
-7
lines changed

Rakefile

Lines changed: 17 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -24,15 +24,25 @@ Rake::TestTask.new(:test) do |test|
2424
end
2525

2626
# Building the gem will use the local file mode, so ensure it's world-readable.
27-
desc 'Check plugin file permissions'
28-
task :check_perms do
29-
plugin = 'lib/fluent/plugin/out_detect_exceptions.rb'
30-
mode = File.stat(plugin).mode & 0o777
31-
raise "Unexpected mode #{mode.to_s(8)} for #{plugin}" unless
32-
mode & 0o444 == 0o444
27+
# https://github.com/GoogleCloudPlatform/fluent-plugin-detect-exceptions/issues/32
28+
desc 'Fix file permissions'
29+
task :fix_perms do
30+
files = [
31+
'lib/fluent/plugin/*.rb'
32+
].flat_map do |file|
33+
file.include?('*') ? Dir.glob(file) : [file]
34+
end
35+
36+
files.each do |file|
37+
mode = File.stat(file).mode & 0o777
38+
next unless mode & 0o444 != 0o444
39+
puts "Changing mode of #{file} from #{mode.to_s(8)} to "\
40+
"#{(mode | 0o444).to_s(8)}"
41+
chmod mode | 0o444, file
42+
end
3343
end
3444

3545
desc 'Run unit tests and RuboCop to check for style violations'
36-
task all: [:test, :rubocop, :check_perms]
46+
task all: [:test, :rubocop, :fix_perms]
3747

3848
task default: :all

0 commit comments

Comments
 (0)