Resolve missing file extension for module relative paths

This commit is contained in:
Pradnya Baviskar 2015-03-17 11:42:04 +05:30
parent c9f377a4c9
commit 187a105333
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', '');