lib/bake/modernize.rb in bake-modernize-0.17.1 vs lib/bake/modernize.rb in bake-modernize-0.17.2
- old
+ new
@@ -1,9 +1,9 @@
# frozen_string_literal: true
# Released under the MIT License.
-# Copyright, 2020-2022, by Samuel Williams.
+# Copyright, 2020-2023, by Samuel Williams.
require_relative 'modernize/license'
require_relative 'modernize/version'
require 'build/files/glob'
require 'fileutils'
@@ -16,10 +16,18 @@
def self.template_path_for(path)
TEMPLATE_ROOT + path
end
+ def self.stale?(source_path, destination_path)
+ if File.exist?(destination_path)
+ return !FileUtils.identical?(source_path, destination_path)
+ end
+
+ return true
+ end
+
def self.copy_template(source_path, destination_path)
glob = Build::Files::Glob.new(source_path, '**/*')
glob.each do |path|
full_path = File.join(destination_path, path.relative_path)
@@ -27,10 +35,10 @@
if File.directory?(path)
unless File.directory?(full_path)
FileUtils.mkdir_p(full_path)
end
else
- unless FileUtils.identical?(path, full_path)
+ if stale?(path, full_path)
FileUtils::Verbose.cp(path, full_path)
end
end
end
end