Merge pull request #109 from PradnyaBaviskar/lb-boot-issue-73-2

Resolve missing file extension for module relative paths
This commit is contained in:
Miroslav Bajtoš 2015-03-18 07:32:33 +01:00
commit 61798455f8
2 changed files with 19 additions and 1 deletions

View File

@ -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);

View File

@ -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', '');