aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--Library/Homebrew/extend/pathname.rb6
1 files changed, 6 insertions, 0 deletions
diff --git a/Library/Homebrew/extend/pathname.rb b/Library/Homebrew/extend/pathname.rb
index c6b575c03..68115632d 100644
--- a/Library/Homebrew/extend/pathname.rb
+++ b/Library/Homebrew/extend/pathname.rb
@@ -131,6 +131,12 @@ class Pathname
open("w", *open_args) { |f| f.write(content) }
end
+ # Only appends to a file that is already created.
+ def append_lines(content, *open_args)
+ raise "Cannot append file that doesn't exist: #{self}" unless exist?
+ open("a", *open_args) { |f| f.puts(content) }
+ end
+
def binwrite(contents, *open_args)
open("wb", *open_args) { |f| f.write(contents) }
end unless method_defined?(:binwrite)