Skip to content

Commit 69bcdf3

Browse files
author
Blessan Mathew
committed
Fix for issue handlebars-lang#517.
Now when compiiled with amd option and a single input argument, we are checking to see whether the input is a file or folder.
1 parent 5ba17c9 commit 69bcdf3

1 file changed

Lines changed: 7 additions & 3 deletions

File tree

bin/handlebars

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -168,10 +168,14 @@ function processTemplate(template, root) {
168168
if (argv.simple) {
169169
output.push(handlebars.precompile(data, options) + '\n');
170170
} else if (argv.partial) {
171-
if(argv.amd && argv._.length == 1){ output.push('return '); }
171+
if(argv.amd && (argv._.length == 1 && !fs.statSync(argv._[0]).isDirectory())) {
172+
output.push('return ');
173+
}
172174
output.push('Handlebars.partials[\'' + template + '\'] = template(' + handlebars.precompile(data, options) + ');\n');
173175
} else {
174-
if(argv.amd && argv._.length == 1){ output.push('return '); }
176+
if(argv.amd && (argv._.length == 1 && !fs.statSync(argv._[0]).isDirectory())) {
177+
output.push('return ');
178+
}
175179
output.push('templates[\'' + template + '\'] = template(' + handlebars.precompile(data, options) + ');\n');
176180
}
177181
}
@@ -184,7 +188,7 @@ argv._.forEach(function(template) {
184188
// Output the content
185189
if (!argv.simple) {
186190
if (argv.amd) {
187-
if(argv._.length > 1){
191+
if(argv._.length > 1 || (argv._.length == 1 && fs.statSync(argv._[0]).isDirectory())) {
188192
if(argv.partial){
189193
output.push('return Handlebars.partials;\n');
190194
} else {

0 commit comments

Comments
 (0)