@@ -25,39 +25,44 @@ export class Directories {
2525 return app . getPath ( 'temp' ) ;
2626 }
2727
28- static simulatorBasePath ( sim : TypeOfSimulator ) : string {
29- return settings . get ( `mainSettings.simulator.${ sim } .basePath` ) as string ;
28+ static simulatorBasePath ( sim : TypeOfSimulator ) : string | null {
29+ return settings . get ( `mainSettings.simulator.${ sim } .basePath` ) ;
3030 }
3131
32- static communityLocation ( sim : TypeOfSimulator ) : string {
33- return settings . get ( `mainSettings.simulator.${ sim } .communityPath` ) as string ;
32+ static communityLocation ( sim : TypeOfSimulator ) : string | null {
33+ return settings . get ( `mainSettings.simulator.${ sim } .communityPath` ) ;
3434 }
3535
36- static inCommunityLocation ( sim : TypeOfSimulator , targetDir : string ) : string {
37- return path . join ( Directories . communityLocation ( sim ) , this . sanitize ( targetDir ) ) ;
36+ static inCommunityLocation ( sim : TypeOfSimulator , targetDir : string ) : string | null {
37+ const communityPath = Directories . communityLocation ( sim ) ;
38+ if ( ! communityPath ) return null ;
39+ return path . join ( communityPath , this . sanitize ( targetDir ) ) ;
3840 }
3941
40- static inCommunityPackage ( addon : Addon , targetDir : string ) : string {
42+ static inCommunityPackage ( addon : Addon , targetDir : string ) : string | null {
4143 const baseDir = this . inCommunityLocation ( addon . simulator , this . sanitize ( addon . targetDirectory ) ) ;
4244 return path . join ( baseDir , this . sanitize ( targetDir ) ) ;
4345 }
4446
45- static installLocation ( sim : TypeOfSimulator ) : string {
46- return settings . get ( `mainSettings.simulator.${ sim } .installPath` ) as string ;
47+ static installLocation ( sim : TypeOfSimulator ) : string | null {
48+ return settings . get ( `mainSettings.simulator.${ sim } .installPath` ) ;
4749 }
4850
49- static inInstallLocation ( sim : TypeOfSimulator , targetDir : string ) : string {
50- return path . join ( Directories . installLocation ( sim ) , this . sanitize ( targetDir ) ) ;
51+ static inInstallLocation ( sim : TypeOfSimulator , targetDir : string ) : string | null {
52+ const installPath = this . installLocation ( sim ) ;
53+ if ( ! installPath ) return null ;
54+ return path . join ( installPath , this . sanitize ( targetDir ) ) ;
5155 }
5256
53- static inInstallPackage ( addon : Addon , targetDir : string ) : string {
57+ static inInstallPackage ( addon : Addon , targetDir : string ) : string | null {
5458 const baseDir = this . inInstallLocation ( addon . simulator , this . sanitize ( addon . targetDirectory ) ) ;
59+ if ( ! baseDir ) return null ;
5560 return path . join ( baseDir , this . sanitize ( targetDir ) ) ;
5661 }
5762
5863 static tempLocation ( sim : TypeOfSimulator ) : string {
5964 return settings . get ( 'mainSettings.separateTempLocation' )
60- ? ( settings . get ( 'mainSettings.tempLocation' ) as string )
65+ ? settings . get ( 'mainSettings.tempLocation' )
6166 : this . installLocation ( sim ) ;
6267 }
6368
0 commit comments