Skip to content

Commit 472f5fa

Browse files
committed
Accept .tt as for templates
1 parent aaeccb6 commit 472f5fa

File tree

2 files changed

+12
-2
lines changed

2 files changed

+12
-2
lines changed

lib/thor/actions.rb

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -131,11 +131,14 @@ def source_paths
131131
# Receives a file or directory and search for it in the source paths.
132132
#
133133
def find_in_source_paths(file)
134+
files = [file, "#{file}.tt"]
134135
relative_root = relative_to_original_destination_root(destination_root, false)
135136

136137
source_paths.each do |source|
137-
source_file = File.expand_path(file, File.join(source, relative_root))
138-
return source_file if File.exist?(source_file)
138+
files.each do |f|
139+
source_file = File.expand_path(f, File.join(source, relative_root))
140+
return source_file if File.exist?(source_file)
141+
end
139142
end
140143

141144
message = "Could not find #{file.inspect} in any of your source paths. "

spec/actions/file_manipulation_spec.rb

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -184,6 +184,13 @@ def file
184184
expect(File.exists?(file)).to be true
185185
end
186186

187+
it "accepts filename without .tt for template method" do
188+
expect(runner).to receive(:file_name).and_return("rdoc")
189+
action :template, "doc/%file_name%.rb"
190+
file = File.join(destination_root, "doc/rdoc.rb")
191+
expect(File.exists?(file)).to be true
192+
end
193+
187194
it "logs status" do
188195
expect(capture(:stdout) { runner.template("doc/config.rb") }).to eq(" create doc/config.rb\n")
189196
end

0 commit comments

Comments
 (0)