20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
|
# File 'lib/docktor_rails/checks/shell_scripts_crlf.rb', line 20
def run(ctx)
root = ctx.fetch(:root)
offenders = []
Dir.glob(File.join(root, "**", "*.sh"), File::FNM_DOTMATCH).each do |path|
next unless File.file?(path)
next if ignored?(path)
offenders << rel(path, root) if File.binread(path).include?("\r\n")
end
if offenders.empty?
pass("No CRLF line endings in .sh files")
else
fail(
"CRLF line endings found in shell scripts",
files: offenders.sort,
hint: "Convert to LF (e.g. with git) and enforce via .gitattributes: *.sh text eol=lf"
)
end
end
|