private getBazelInfo()

in src/debug-adapter/client.ts [539:573]


  private getBazelInfo(
    bazelExecutable: string,
    cwd: string,
  ): Promise<Map<string, string>> {
    return new Promise((resolve, reject) => {
      const execOptions = {
        cwd,
        // The maximum amount of data allowed on stdout. 500KB should be plenty
        // of `bazel info`, but if this becomes problematic we can switch to the
        // event-based `child_process` APIs instead.
        maxBuffer: 500 * 1024,
      };
      child_process.execFile(
        bazelExecutable,
        ["info"],
        execOptions,
        (error: Error, stdout: string, stderr: string) => {
          if (error) {
            reject(error);
          } else {
            const keyValues = new Map<string, string>();
            const lines = stdout.trim().split("\n");
            for (const line of lines) {
              // Windows paths can have >1 ':', so can't use line.split(":", 2)
              const splitterIndex = line.indexOf(":");
              const key = line.substring(0, splitterIndex);
              const value = line.substring(splitterIndex + 1);
              keyValues.set(key.trim(), value.trim());
            }
            resolve(keyValues);
          }
        },
      );
    });
  }