Before copying file, explicitly remove the old one

On Windows, FileUtils.cp(path, dest_path) will fail with a Permission
Denied if the dest_path already exists and is read-only. People have
complained about this since at least 2008.

This lets `jekyll build` work without error in Windows when one or more
read-only files exist.

This change will accommodate users of Team Foundation, which uses the
read-only flag for for source control status. (dumb, I know, but but a
real problem)
This commit is contained in:
Simon Sarris 2014-06-19 18:25:00 -04:00
parent 5846cc7b70
commit 74f0f27d18
1 changed files with 1 additions and 0 deletions

View File

@ -59,6 +59,7 @@ module Jekyll
@@mtimes[path] = mtime
FileUtils.mkdir_p(File.dirname(dest_path))
FileUtils.rm(dest_path) if File.exist?(dest_path)
FileUtils.cp(path, dest_path)
true