Skip to content

Commit

Permalink
Merge pull request #1016 from JackMordaunt/config-panic-fix
Browse files Browse the repository at this point in the history
[Fix] Panic when using npm start on OSX fresh dev setup. Resolves #1017.
  • Loading branch information
jakejarrett authored Jan 5, 2018
2 parents c898968 + cf0ae2e commit 61542fd
Showing 1 changed file with 17 additions and 5 deletions.
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

0 comments on commit 61542fd

Please sign in to comment.