Skip to content

Commit

Permalink
Uses input pipe for rubocop instead of writing a file
Browse files Browse the repository at this point in the history
  • Loading branch information
bougyman committed Apr 11, 2024
1 parent af95427 commit d94b067
Showing 1 changed file with 9 additions and 3 deletions.
12 changes: 9 additions & 3 deletions exe/namespacer
Original file line number Diff line number Diff line change
Expand Up @@ -69,16 +69,22 @@ def new_path(path)
dir.join("#{base}.namespaced#{ext}")
end

def namespace_file(namespace, path)
def namespace_file(namespace, path) # rubocop:disable Metrics/AbcSize, Metrics/MethodLength
namespaced = Rubyists::Namespacer.namespace!(path.read, namespace)
write_path = Rubyists::Namespacer.cli_options.in_place ? path : new_path(path)
if Rubyists::Namespacer.cli_options.verbose
msg = "Namespacing #{write_path} with #{namespace}"
msg << ' (in-place)' if Rubyists::Namespacer.cli_options.in_place
warn msg
end
write_path.write(namespaced)
Rubyists::Namespacer.cmd.run(:rubocop, '-A', write_path.to_s)
cmd = Rubyists::Namespacer.cmd.run(:rubocop,
'-A',
'--stdin',
write_path.basename.to_s,
'--stderr',
input: namespaced,
only_output_on_error: true)
write_path.write(cmd.out)
end

paths.each do |path|
Expand Down

0 comments on commit d94b067

Please sign in to comment.