Method: Hanami::Utils::Files.remove_line

Defined in:
lib/hanami/utils/files.rb

.remove_line(path, target) ⇒ Object

Removes line from path, matching target.

Raises:

  • (Errno::ENOENT)

    if the path doesn’t exist

  • (ArgumentError)

    if target cannot be found in path

Since:

  • 1.1.0



277
278
279
280
281
282
283
# File 'lib/hanami/utils/files.rb', line 277

def self.remove_line(path, target)
  content = ::File.readlines(path)
  i       = index(content, path, target)

  content.delete_at(i)
  write(path, content)
end