in eng/tools/typespec-validation/src/rules/format.ts [9:51]
async execute(host: TsvHost, folder: string): Promise<RuleResult> {
let success = true;
let stdOutput = "";
let errorOutput = "";
let [err, stdout, stderr] = await host.runCmd(
'npm exec --no -- tsp format "../**/*.tsp"', // Format parent folder to include shared files
folder,
);
if (err) {
success = false;
errorOutput += err.message;
}
stdOutput += stdout;
errorOutput += stderr;
[err, stdout, stderr] = await host.runCmd(
"npm exec --no -- prettier --write tspconfig.yaml",
folder,
);
if (err) {
success = false;
errorOutput += err.message;
}
stdOutput += stdout;
errorOutput += stderr;
if (success) {
const gitDiffResult = await host.gitDiffTopSpecFolder(host, folder);
stdOutput += gitDiffResult.stdOutput;
if (!gitDiffResult.success) {
success = false;
errorOutput += gitDiffResult.errorOutput;
errorOutput += `\nFiles have been changed after \`tsp format\`. Run \`tsp format\` and ensure all files are included in your change.`;
}
}
return {
success: success,
stdOutput: stdOutput,
errorOutput: errorOutput,
};
}