Use 'firstDefined' in 'enablePlugin' (#23825)

This commit is contained in:
Andy 2018-05-02 15:37:22 -07:00 committed by GitHub
parent d8b0791fe8
commit 5aa0a79dac
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -1092,14 +1092,14 @@ namespace ts.server {
this.projectService.logger.info(message);
};
for (const searchPath of searchPaths) {
const resolvedModule = <PluginModuleFactory>Project.resolveModule(pluginConfigEntry.name, searchPath, this.projectService.host, log);
if (resolvedModule) {
this.enableProxy(resolvedModule, pluginConfigEntry);
return;
}
const resolvedModule = firstDefined(searchPaths, searchPath =>
<PluginModuleFactory | undefined>Project.resolveModule(pluginConfigEntry.name, searchPath, this.projectService.host, log));
if (resolvedModule) {
this.enableProxy(resolvedModule, pluginConfigEntry);
}
else {
this.projectService.logger.info(`Couldn't find ${pluginConfigEntry.name}`);
}
this.projectService.logger.info(`Couldn't find ${pluginConfigEntry.name}`);
}
private enableProxy(pluginModuleFactory: PluginModuleFactory, configEntry: PluginImport) {