lib/hx.rb in hx-0.8.3 vs lib/hx.rb in hx-0.8.4
- old
+ new
@@ -539,25 +539,27 @@
def get_entry(path)
@combined_output.get_entry(path)
end
end
-def self.refresh_file(pathname, content, update_time)
+def self.refresh_file(pathname, content, update_time, executable=false)
begin
return false if update_time and update_time < pathname.mtime
rescue Errno::ENOENT
end
- write_file(pathname, content)
+ write_file(pathname, content, executable)
true
end
-def self.write_file(pathname, content)
+def self.write_file(pathname, content, executable=false)
parent = pathname.parent
parent.mkpath()
tempfile = Tempfile.new('.hx-out', parent.to_s)
begin
File.open(tempfile.path, "wb") { |stream| stream << content.to_s }
- File.chmod(0666 & ~File.umask, tempfile.path)
+ base_mode = 0666
+ base_mode |= 0111 if executable
+ File.chmod(base_mode & ~File.umask, tempfile.path)
File.rename(tempfile.path, pathname.to_s)
ensure
tempfile.unlink
end
nil