Pathname.atomic_write
This commit is contained in:
parent
2ace9422bc
commit
e6cb8cbee9
@ -1,4 +1,3 @@
|
|||||||
require 'tempfile'
|
|
||||||
|
|
||||||
HOMEBREW_LIBRARY = HOMEBREW_REPOSITORY/"Library"
|
HOMEBREW_LIBRARY = HOMEBREW_REPOSITORY/"Library"
|
||||||
|
|
||||||
@ -43,10 +42,7 @@ module Homebrew extend self
|
|||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
tf = Tempfile.new("brew-tap")
|
HOMEBREW_LIBRARY.join("Formula/.gitignore").atomic_write(ignores.uniq.join("\n"))
|
||||||
tf.write(ignores.uniq.join("\n"))
|
|
||||||
tf.close
|
|
||||||
mv tf.path, "#{HOMEBREW_LIBRARY}/Formula/.gitignore"
|
|
||||||
end
|
end
|
||||||
|
|
||||||
private
|
private
|
||||||
|
@ -1,5 +1,4 @@
|
|||||||
require 'cmd/tap' # for Pathname.recursive_formula
|
require 'cmd/tap' # for tap_args
|
||||||
require 'tempfile'
|
|
||||||
|
|
||||||
module Homebrew extend self
|
module Homebrew extend self
|
||||||
def untap
|
def untap
|
||||||
@ -18,9 +17,6 @@ module Homebrew extend self
|
|||||||
end
|
end
|
||||||
rm_rf tapd
|
rm_rf tapd
|
||||||
|
|
||||||
tf = Tempfile.new("brew-untap")
|
HOMEBREW_REPOSITORY.join("Library/Formula/.gitignore").atomic_write(gitignores * "\n")
|
||||||
tf.write(gitignores.join("\n"))
|
|
||||||
tf.close
|
|
||||||
mv tf.path, "#{HOMEBREW_PREFIX}/Library/Formula/.gitignore"
|
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
@ -90,6 +90,15 @@ class Pathname
|
|||||||
File.open(self, 'w') {|f| f.write content }
|
File.open(self, 'w') {|f| f.write content }
|
||||||
end
|
end
|
||||||
|
|
||||||
|
# NOTE always overwrites
|
||||||
|
def atomic_write content
|
||||||
|
require 'tempfile'
|
||||||
|
tf = Tempfile.new(self.basename.to_s)
|
||||||
|
tf.write(content)
|
||||||
|
tf.close
|
||||||
|
FileUtils.mv tf.path, self.to_s
|
||||||
|
end
|
||||||
|
|
||||||
def cp dst
|
def cp dst
|
||||||
if file?
|
if file?
|
||||||
FileUtils.cp to_s, dst
|
FileUtils.cp to_s, dst
|
||||||
|
Loading…
x
Reference in New Issue
Block a user