function executeBuildifier()

in src/buildifier/buildifier.ts [182:211]


function executeBuildifier(
  fileContent: string,
  args: string[],
  acceptNonSevereErrors: boolean,
): Promise<{ stdout: string; stderr: string }> {
  return new Promise((resolve, reject) => {
    const execOptions = {
      maxBuffer: Number.MAX_SAFE_INTEGER,
    };
    const process = child_process.execFile(
      getDefaultBuildifierExecutablePath(),
      args,
      execOptions,
      (error: Error, stdout: string, stderr: string) => {
        if (
          !error ||
          (acceptNonSevereErrors && shouldTreatBuildifierErrorAsSuccess(error))
        ) {
          resolve({ stdout, stderr });
        } else {
          reject(error);
        }
      },
    );
    // Write the file being linted/formatted to stdin and close the stream so
    // that the buildifier process continues.
    process.stdin.write(fileContent);
    process.stdin.end();
  });
}