private async processConnectionDir()

in src/server/connection-details.ts [45:82]


  private async processConnectionDir(
    bspServerName: string,
    repoRoot: string
  ): Promise<BspConnectionDetails | undefined> {
    let result: BspConnectionDetails | undefined = undefined

    const bspDir = path.join(repoRoot, '.bsp')
    let allFiles: string[] = []
    try {
      allFiles = await Utils.readdir(bspDir)
    } catch {
      this.outputChannel.appendLine(`Unable to access ${bspDir}.`)
      return result
    }

    this.outputChannel.appendLine(
      `Found ${bspDir}, checking for server connection details.`
    )

    // Collect all json files from the bsp connection directory.
    const jsonFiles = allFiles.filter(file => file.endsWith('.json'))

    // Evaluate each file to find the best match for the requested server.
    for (const fileName of jsonFiles) {
      const connectionInfo = await this.processConnectionFile(
        path.join(bspDir, fileName)
      )
      if (connectionInfo && connectionInfo.name === bspServerName) {
        if (
          result === undefined ||
          semver.gt(connectionInfo.version, result.version)
        ) {
          result = connectionInfo
        }
      }
    }
    return result
  }