@@ -7,13 +7,14 @@ import MetaData from "../interfaces/MetaData";
77import  {  getLogger  }  from  "../utils/logger" ; 
88import  Properties  from  "./Properties" ; 
99import  {  getApplyThemeTemplate  }  from  "../components/apply-theme/applyTheme" ; 
10+ import  {  join  }  from  "path" ; 
1011
1112class  ModManager  { 
1213    private  static  logger  =  getLogger ( "ModManager" ) ; 
1314
1415    public  static  loadPlugin ( pluginName :string )  { 
1516        if ( document . getElementById ( pluginName ) )  return ; 
16-         let  plugin  =  readFileSync ( ` ${ Properties . pluginsPath } \\ ${ pluginName } ` ,  "utf-8" ) ; 
17+         let  plugin  =  readFileSync ( join ( properties . pluginsPath ,   pluginName ) ,  "utf-8" ) ; 
1718        let  script  =  document . createElement ( "script" ) ; 
1819        script . innerHTML  =  plugin 
1920        script . id  =  pluginName 
@@ -77,23 +78,44 @@ class ModManager {
7778        } ) 
7879    } 
7980
80-     
8181    public  static  openThemesFolder ( )  { 
8282        helpers . waitForElm ( "#openthemesfolderBtn" ) . then ( ( )  =>  { 
83-             let  button  =  document . getElementById ( "openthemesfolderBtn" ) ; 
84-             button . addEventListener ( "click" ,  ( )  =>  { 
85-                 exec ( `start "" " ${ Properties . themesPath } "` ) ; 
86-             } ) 
87-         } ) 
83+             const  button  =  document . getElementById ( "openthemesfolderBtn" ) ; 
84+             button ? .addEventListener ( "click" ,  ( )  =>  { 
85+                 this . openFolder ( Properties . themesPath ) ; 
86+             } ) ; 
87+         } ) ; 
8888    } 
89-      
89+ 
9090    public  static  openPluginsFolder ( )  { 
9191        helpers . waitForElm ( "#openpluginsfolderBtn" ) . then ( ( )  =>  { 
92-             let  button  =  document . getElementById ( "openpluginsfolderBtn" ) ; 
93-             button . addEventListener ( "click" ,  ( )  =>  { 
94-                 exec ( `start "" "${ Properties . pluginsPath }  ) ; 
95-             } ) 
96-         } ) 
92+             const  button  =  document . getElementById ( "openpluginsfolderBtn" ) ; 
93+             button ?. addEventListener ( "click" ,  ( )  =>  { 
94+                 this . openFolder ( Properties . pluginsPath ) ; 
95+             } ) ; 
96+         } ) ; 
97+     } 
98+ 
99+     private  static  openFolder ( folderPath : string )  { 
100+         let  command : string ; 
101+ 
102+         switch  ( process . platform )  { 
103+             case  "win32" :
104+                 command  =  `start "" "${ folderPath }  ; 
105+                 break ; 
106+             case  "darwin" :
107+                 command  =  `open "${ folderPath }  ; 
108+                 break ; 
109+             default :
110+                 command  =  `xdg-open "${ folderPath }  ; 
111+                 break ; 
112+         } 
113+ 
114+         exec ( command ,  ( error )  =>  { 
115+             if  ( error )  { 
116+                 console . error ( `Failed to open folder: ${ folderPath }  ,  error ) ; 
117+             } 
118+         } ) ; 
97119    } 
98120
99121    public  static  scrollListener ( )  { 
@@ -165,8 +187,8 @@ class ModManager {
165187        if ( itemFile . endsWith ( ".theme.css" ) )  pluginOrTheme  =  "theme" ; 
166188        else  pluginOrTheme  =  "plugin" ; 
167189
168-         let  itemPath  =  ` ${ pluginOrTheme  ==  "theme"  ? properties . themesPath  : properties . pluginsPath } \\ ${ itemFile } ` ; 
169- 
190+         const  itemPath  =  join ( pluginOrTheme  ===   "theme"  ? properties . themesPath  : properties . pluginsPath ,   itemFile ) ; 
191+          
170192        let  installedItemMetaData :MetaData  =  helpers . extractMetadataFromFile ( itemPath ) ; 
171193        if  ( installedItemMetaData  &&  Object . keys ( installedItemMetaData ) . length  >  0 )  { 
172194            let  updateUrl  =  installedItemMetaData . updateUrl ; 
0 commit comments