Skip to content

Commit

Permalink
Support (changed) behaviour when writing to an existing file causes a…
Browse files Browse the repository at this point in the history
… permission denied error
  • Loading branch information
yrashk committed Dec 6, 2012
1 parent 4cca6f4 commit 9fc2312
Showing 1 changed file with 3 additions and 0 deletions.
3 changes: 3 additions & 0 deletions lib/release.ex
Original file line number Diff line number Diff line change
Expand Up @@ -227,6 +227,9 @@ defmodule Relex.Release do
content = File.read!(template)
new_content = String.replace(content, "%FINAL_ROOTDIR%", "$(cd ${0%/*} && pwd)/../..", global: true)
new_file = File.join([target, "bin", File.basename(template, ".src")])
if File.exists?(new_file) do
:file.delete(new_file)
end
File.write!(new_file, new_content)
stat = File.stat!(template)
File.write_stat!(new_file, File.Stat.mode(493, stat))
Expand Down

0 comments on commit 9fc2312

Please sign in to comment.