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 = {
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
You can’t perform that action at this time.
0 commit comments