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
|
// require directories
|
||||||
var bootDirs = options.bootDirs || []; // precedence
|
var bootDirs = options.bootDirs || []; // precedence
|
||||||
bootDirs = bootDirs.concat(path.join(appRootDir, 'boot'));
|
bootDirs = bootDirs.concat(path.join(appRootDir, 'boot'));
|
||||||
|
resolveRelativePaths(bootDirs, appRootDir);
|
||||||
|
|
||||||
var bootScripts = options.bootScripts || [];
|
var bootScripts = options.bootScripts || [];
|
||||||
|
resolveRelativePaths(bootScripts, appRootDir);
|
||||||
|
|
||||||
bootDirs.forEach(function(dir) {
|
bootDirs.forEach(function(dir) {
|
||||||
bootScripts = bootScripts.concat(findScripts(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]);
|
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() {
|
it('ignores models/ subdirectory', function() {
|
||||||
appdir.createConfigFilesSync();
|
appdir.createConfigFilesSync();
|
||||||
appdir.writeFileSync('models/my-model.js', '');
|
appdir.writeFileSync('models/my-model.js', '');
|
||||||
|
|
Loading…
Reference in New Issue