Edit mode: fix bug when XDG_DATA_DIRS is empty

This commit is contained in:
wpetit 2015-11-12 15:06:29 +01:00
parent 369bcceeb9
commit b92934fedc
1 changed files with 11 additions and 3 deletions

View File

@ -28,12 +28,20 @@ exports.loadDesktopApps = function() {
logger.info('Loading desktop apps...');
var baseDirs = global.process.env.XDG_DATA_DIRS.split(':').map(function(baseDir){
dispatch({ type: LOAD_DESKTOP_APPS });
var xdgDataDirs = global.process.env.XDG_DATA_DIRS;
if( !xdgDataDirs ) {
logger.warn('The environment variable XDG_DATA_DIRS is empty. Can\'t find any application.');
dispatch({ type: LOAD_DESKTOP_APPS_SUCCESS, desktopApps: [] });
return;
}
var baseDirs = xdgDataDirs.split(':').map(function(baseDir){
return path.join(baseDir, 'applications');
});
dispatch({ type: LOAD_DESKTOP_APPS });
return Util.DesktopApps.loadAllDesktopFiles(baseDirs)
.then(function(desktopApps) {
logger.info('Desktop apps loaded.');