Thanks to visit codestin.com
Credit goes to github.com

Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
22 changes: 17 additions & 5 deletions app/public/js/common/configLocation.js
Original file line number Diff line number Diff line change
Expand Up @@ -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
*
Expand All @@ -27,7 +39,6 @@ const configuration = {
userConfigPath = `${userHome}/.config/Soundnode`;
}


/** Linux platforms - XDG Standard */
if (process.platform === 'linux') {
userConfigPath = `${userHome}/.config/Soundnode`;
Expand All @@ -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;
},

Expand Down