Method: Staticky::Files#append

Defined in:
lib/staticky/files.rb

#append(path, contents) ⇒ Object

Adds a new line at the bottom of the file

Parameters:

  • path (String, Pathname)

    the path to file

  • contents (String)

    the contents to add

Raises:

See Also:

Since:

  • 0.1.0



317
318
319
320
321
322
323
324
325
326
# File 'lib/staticky/files.rb', line 317

def append(path, contents)
  mkdir_p(path)
  touch(path)

  content = adapter.readlines(path)
  content << newline unless newline?(content.last)
  content << newline(contents)

  write(path, content)
end