@@ -38,15 +38,14 @@ export class MacOsSplitTunnelingAppListRetriever implements ISplitTunnelingAppLi
38
38
fromCache = false ;
39
39
40
40
const applicationBundlePaths = await this . findApplicationBundlePaths ( ) ;
41
- for ( const applicationBundlePath of applicationBundlePaths ) {
42
- // `getApplication updates the cache so no need to use the result.`
43
- await this . getApplication ( applicationBundlePath , false ) ;
44
- }
45
-
46
41
const executablePaths = this . additionalApplications . values ( ) ;
47
- for ( const executablePath of executablePaths ) {
48
- await this . getApplication ( executablePath , true ) ;
49
- }
42
+ await Promise . all ( [
43
+ // `getApplication updates the cache so no need to use the result.`
44
+ ...applicationBundlePaths . map ( ( applicationBundlePath ) =>
45
+ this . getApplication ( applicationBundlePath , false ) ,
46
+ ) ,
47
+ ...executablePaths . map ( ( executablePath ) => this . getApplication ( executablePath , true ) ) ,
48
+ ] ) ;
50
49
}
51
50
52
51
// Return applications from cache.
@@ -56,20 +55,19 @@ export class MacOsSplitTunnelingAppListRetriever implements ISplitTunnelingAppLi
56
55
public async getMetadataForApplications (
57
56
applicationPaths : string [ ] ,
58
57
) : Promise < { fromCache : boolean ; applications : ISplitTunnelingApplication [ ] } > {
59
- for ( const applicationPath of applicationPaths ) {
60
- if ( ! this . applicationCache . includes ( applicationPath ) ) {
61
- await this . addApplicationPathToCache ( applicationPath ) ;
62
- }
63
- }
58
+ await Promise . all (
59
+ applicationPaths
60
+ . filter ( ( applicationPath ) => ! this . applicationCache . includes ( applicationPath ) )
61
+ . map ( ( applicationPath ) => this . addApplicationPathToCache ( applicationPath ) ) ,
62
+ ) ;
64
63
65
64
const applications = await this . getApplications ( ) ;
66
65
67
- applications . applications = applications . applications . filter (
68
- ( application ) =>
69
- applicationPaths . find (
70
- ( applicationPath ) =>
71
- applicationPath . toLowerCase ( ) === application . absolutepath . toLowerCase ( ) ,
72
- ) !== undefined ,
66
+ applications . applications = applications . applications . filter ( ( application ) =>
67
+ applicationPaths . some (
68
+ ( applicationPath ) =>
69
+ applicationPath . toLowerCase ( ) === application . absolutepath . toLowerCase ( ) ,
70
+ ) ,
73
71
) ;
74
72
75
73
return applications ;
@@ -82,7 +80,7 @@ export class MacOsSplitTunnelingAppListRetriever implements ISplitTunnelingAppLi
82
80
83
81
public async addApplicationPathToCache ( applicationPath : string ) : Promise < void > {
84
82
const application = await this . getApplication ( applicationPath , true ) ;
85
- if ( application !== undefined && application . deletable ) {
83
+ if ( application ? .deletable ) {
86
84
this . additionalApplications . add ( application ) ;
87
85
}
88
86
}
@@ -113,7 +111,7 @@ export class MacOsSplitTunnelingAppListRetriever implements ISplitTunnelingAppLi
113
111
}
114
112
115
113
private async findApplicationBundlePaths ( ) {
116
- const readdirPromises = this . getAppDirectories ( ) . map ( async ( directory ) =>
114
+ const readdirPromises = this . getAppDirectories ( ) . map ( ( directory ) =>
117
115
this . readDirectory ( directory ) ,
118
116
) ;
119
117
const applicationBundlePaths = ( await Promise . all ( readdirPromises ) ) . flat ( ) ;
0 commit comments