From 471cf1d51a0fc9cb8713e8d73bb6beb19942ac9b Mon Sep 17 00:00:00 2001 From: Breckin Loggins Date: Sat, 16 Jul 2011 14:42:45 -0500 Subject: [PATCH] Issue #1470: Cleaning up logic on extension detection --- lib/command.js | 2 +- src/command.coffee | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/lib/command.js b/lib/command.js index b923d7c8..ff102fdc 100644 --- a/lib/command.js +++ b/lib/command.js @@ -62,7 +62,7 @@ base = path.join(source); compile = function(source, sourceIndex, topLevel) { return path.exists(source, function(exists) { - if (topLevel && !exists && source.lastIndexOf(".coffee") === -1) { + if (topLevel && !exists && source.slice(-7) !== '.coffee') { return compile(source + ".coffee", sourceIndex, topLevel); } if (topLevel && !exists) { diff --git a/src/command.coffee b/src/command.coffee index 5c008b8d..f1ef9539 100644 --- a/src/command.coffee +++ b/src/command.coffee @@ -78,7 +78,7 @@ compileScripts = -> base = path.join(source) compile = (source, sourceIndex, topLevel) -> path.exists source, (exists) -> - if topLevel and not exists and source.lastIndexOf(".coffee") == -1 + if topLevel and not exists and source[-7..] isnt '.coffee' return compile source + ".coffee", sourceIndex, topLevel throw new Error "File not found: #{source}" if topLevel and not exists