From 187a10533370361bb9ffa76e2bfe8baf88a21f0a Mon Sep 17 00:00:00 2001 From: Pradnya Baviskar Date: Tue, 17 Mar 2015 11:42:04 +0530 Subject: [PATCH] Resolve missing file extension for module relative paths --- lib/compiler.js | 8 +++++++- test/compiler.test.js | 12 ++++++++++++ 2 files changed, 19 insertions(+), 1 deletion(-) diff --git a/lib/compiler.js b/lib/compiler.js index 4d0d2bb..5958b03 100644 --- a/lib/compiler.js +++ b/lib/compiler.js @@ -312,7 +312,13 @@ function resolveAppPath(rootDir, relativePath) { fullPath = modulePaths .map(function(candidateDir) { - return path.join(candidateDir, relativePath); + try { + var filePath = path.join(candidateDir, relativePath); + filePath = require.resolve(filePath); + return filePath; + } catch (err) { + return filePath; + } }) .filter(function(candidate) { return fs.existsSync(candidate); diff --git a/test/compiler.test.js b/test/compiler.test.js index aef0dce..9b1ce03 100644 --- a/test/compiler.test.js +++ b/test/compiler.test.js @@ -469,6 +469,18 @@ describe('compiler', function() { expect(instructions.files.boot).to.eql([initJs]); }); + it('resolves missing extensions in `bootScripts` in module relative path', + function() { + appdir.createConfigFilesSync(); + var initJs = appdir.writeFileSync('node_modules/custom-boot/init.js', ''); + + var instructions = boot.compile({ + appRootDir: appdir.PATH, + bootScripts: ['custom-boot/init'] + }); + expect(instructions.files.boot).to.eql([initJs]); + }); + it('ignores index.js in `bootDirs`', function() { appdir.createConfigFilesSync(); appdir.writeFileSync('custom-boot/index.js', '');