async execute()

in eng/tools/typespec-validation/src/rules/emit-autorest.ts [12:42]


  async execute(host: TsvHost, folder: string): Promise<RuleResult> {
    let success = true;
    let stdOutput = "";
    let errorOutput = "";

    const mainTspExists = await host.checkFileExists(join(folder, "main.tsp"));
    stdOutput += `mainTspExists: ${mainTspExists}\n`;

    if (mainTspExists) {
      const configText = await host.readTspConfig(folder);
      const config = yamlParse(configText);

      const emit = config?.emit;
      stdOutput += `emit: ${JSON.stringify(emit)}\n`;

      if (!emit?.includes("@azure-tools/typespec-autorest")) {
        success = false;
        errorOutput +=
          "tspconfig.yaml must include the following emitter by default:\n" +
          "\n" +
          "emit:\n" +
          '  - "@azure-tools/typespec-autorest"\n';
      }
    }

    return {
      success: success,
      stdOutput: stdOutput,
      errorOutput: errorOutput,
    };
  }