Skip to content

Commit cb57908

Browse files
committed
Refactored for clarity.
1 parent 349d2c4 commit cb57908

1 file changed

Lines changed: 5 additions & 10 deletions

File tree

app/public/js/common/configLocation.js

Lines changed: 5 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,6 @@ const configuration = {
2727
userConfigPath = `${userHome}/.config/Soundnode`;
2828
}
2929

30-
3130
/** Linux platforms - XDG Standard */
3231
if (process.platform === 'linux') {
3332
userConfigPath = `${userHome}/.config/Soundnode`;
@@ -38,20 +37,16 @@ const configuration = {
3837
userConfigPath = `${userHome}/Library/Preferences/Soundnode`;
3938
}
4039

41-
// Guard to assert type of string.
42-
if (typeof userConfigPath !== "string") {
43-
throw `Could not set userConfigPath for this OS ${process.platform}`
40+
/** Unsupported platform */
41+
if (userConfigPath === null) {
42+
throw `could not set config path for this OS ${process.platform}`
4443
}
4544

4645
// create user config in path
4746
// if there is no userConfig path
48-
//
49-
// fs.statSync will throw an exception if
50-
// any directory along the path doesn't exist.
51-
// Solution: use try catch.
5247
try {
53-
var fi = fs.statSync(userConfigPath);
54-
if (!fi.isDirectory()) {
48+
const configFileInfo = fs.statSync(userConfigPath);
49+
if (!configFileInfo.isDirectory()) {
5550
this.createUserConfig(userConfigPath);
5651
}
5752
}

0 commit comments

Comments
 (0)