File tree Expand file tree Collapse file tree 1 file changed +17
-5
lines changed Expand file tree Collapse file tree 1 file changed +17
-5
lines changed Original file line number Diff line number Diff line change @@ -14,6 +14,18 @@ const configuration = {
14
14
} ) ;
15
15
} ,
16
16
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
+
17
29
/**
18
30
* Get the configuration folder location
19
31
*
@@ -27,7 +39,6 @@ const configuration = {
27
39
userConfigPath = `${ userHome } /.config/Soundnode` ;
28
40
}
29
41
30
-
31
42
/** Linux platforms - XDG Standard */
32
43
if ( process . platform === 'linux' ) {
33
44
userConfigPath = `${ userHome } /.config/Soundnode` ;
@@ -38,12 +49,13 @@ const configuration = {
38
49
userConfigPath = `${ userHome } /Library/Preferences/Soundnode` ;
39
50
}
40
51
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 } `
45
55
}
46
56
57
+ this . createIfNotExist ( userConfigPath )
58
+
47
59
return userConfigPath ;
48
60
} ,
49
61
You can’t perform that action at this time.
0 commit comments