Merge pull request #104 from PradnyaBaviskar/lb-explorer-issue-65
Resolve relative paths in bootScripts using appRootDir
This commit is contained in:
commit
cb7ca7d9ad
|
@ -62,8 +62,11 @@ module.exports = function compile(options) {
|
|||
// require directories
|
||||
var bootDirs = options.bootDirs || []; // precedence
|
||||
bootDirs = bootDirs.concat(path.join(appRootDir, 'boot'));
|
||||
resolveRelativePaths(bootDirs, appRootDir);
|
||||
|
||||
var bootScripts = options.bootScripts || [];
|
||||
resolveRelativePaths(bootScripts, appRootDir);
|
||||
|
||||
bootDirs.forEach(function(dir) {
|
||||
bootScripts = bootScripts.concat(findScripts(dir));
|
||||
});
|
||||
|
@ -497,3 +500,12 @@ function buildComponentInstructions(rootDir, componentConfig) {
|
|||
};
|
||||
});
|
||||
}
|
||||
|
||||
function resolveRelativePaths(relativePaths, appRootDir) {
|
||||
relativePaths.forEach(function(relativePath, k) {
|
||||
var start = relativePath.substring(0, 2);
|
||||
if (start === './' || start === '..') {
|
||||
relativePaths[k] = path.resolve(appRootDir, relativePath);
|
||||
}
|
||||
});
|
||||
}
|
||||
|
|
|
@ -417,6 +417,28 @@ describe('compiler', function() {
|
|||
expect(instructions.files.boot).to.eql([initJs]);
|
||||
});
|
||||
|
||||
it('should resolve relative path in `bootScripts`', function() {
|
||||
appdir.createConfigFilesSync();
|
||||
var initJs = appdir.writeFileSync('custom-boot/init.js',
|
||||
'module.exports = function(app) { app.fnCalled = true; };');
|
||||
var instructions = boot.compile({
|
||||
appRootDir: appdir.PATH,
|
||||
bootScripts: ['./custom-boot/init.js']
|
||||
});
|
||||
expect(instructions.files.boot).to.eql([initJs]);
|
||||
});
|
||||
|
||||
it('should resolve relative path in `bootDirs`', function() {
|
||||
appdir.createConfigFilesSync();
|
||||
var initJs = appdir.writeFileSync('custom-boot/init.js',
|
||||
'module.exports = function(app) { app.fnCalled = true; };');
|
||||
var instructions = boot.compile({
|
||||
appRootDir: appdir.PATH,
|
||||
bootDirs:['./custom-boot']
|
||||
});
|
||||
expect(instructions.files.boot).to.eql([initJs]);
|
||||
});
|
||||
|
||||
it('ignores models/ subdirectory', function() {
|
||||
appdir.createConfigFilesSync();
|
||||
appdir.writeFileSync('models/my-model.js', '');
|
||||
|
|
Loading…
Reference in New Issue