Skip to content

Commit 61542fd

Browse files
authored
Merge pull request #1016 from JackMordaunt/config-panic-fix
[Fix] Panic when using npm start on OSX fresh dev setup. Resolves #1017.
2 parents c898968 + cf0ae2e commit 61542fd

File tree

1 file changed

+17
-5
lines changed

1 file changed

+17
-5
lines changed

app/public/js/common/configLocation.js

Lines changed: 17 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,18 @@ const configuration = {
1414
});
1515
},
1616

17+
createIfNotExist(path) {
18+
try {
19+
const pathInfo = fs.statSync(path);
20+
if (!pathInfo.isDirectory()) {
21+
this.createUserConfig(path);
22+
}
23+
}
24+
catch(error) {
25+
this.createUserConfig(path);
26+
}
27+
},
28+
1729
/**
1830
* Get the configuration folder location
1931
*
@@ -27,7 +39,6 @@ const configuration = {
2739
userConfigPath = `${userHome}/.config/Soundnode`;
2840
}
2941

30-
3142
/** Linux platforms - XDG Standard */
3243
if (process.platform === 'linux') {
3344
userConfigPath = `${userHome}/.config/Soundnode`;
@@ -38,12 +49,13 @@ const configuration = {
3849
userConfigPath = `${userHome}/Library/Preferences/Soundnode`;
3950
}
4051

41-
// create user config in path
42-
// if there is no userConfig path
43-
if (!fs.statSync(userConfigPath).isDirectory()) {
44-
this.createUserConfig()
52+
/** Unsupported platform */
53+
if (userConfigPath === null) {
54+
throw `could not set config path for this OS ${process.platform}`
4555
}
4656

57+
this.createIfNotExist(userConfigPath)
58+
4759
return userConfigPath;
4860
},
4961

0 commit comments

Comments
 (0)