diff --git a/app/public/js/common/configLocation.js b/app/public/js/common/configLocation.js index 8dda7e44..d9a7cfb1 100644 --- a/app/public/js/common/configLocation.js +++ b/app/public/js/common/configLocation.js @@ -14,6 +14,18 @@ const configuration = { }); }, + createIfNotExist(path) { + try { + const pathInfo = fs.statSync(path); + if (!pathInfo.isDirectory()) { + this.createUserConfig(path); + } + } + catch(error) { + this.createUserConfig(path); + } + }, + /** * Get the configuration folder location * @@ -27,7 +39,6 @@ const configuration = { userConfigPath = `${userHome}/.config/Soundnode`; } - /** Linux platforms - XDG Standard */ if (process.platform === 'linux') { userConfigPath = `${userHome}/.config/Soundnode`; @@ -38,12 +49,13 @@ const configuration = { userConfigPath = `${userHome}/Library/Preferences/Soundnode`; } - // create user config in path - // if there is no userConfig path - if (!fs.statSync(userConfigPath).isDirectory()) { - this.createUserConfig() + /** Unsupported platform */ + if (userConfigPath === null) { + throw `could not set config path for this OS ${process.platform}` } + this.createIfNotExist(userConfigPath) + return userConfigPath; },