Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
18 changes: 4 additions & 14 deletions eng/tools/summarize-impact/src/cli.ts
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
#!/usr/bin/env node

import { getChangedFilesStatuses } from "@azure-tools/specs-shared/changed-files";
Expand All @@ -8,14 +8,13 @@
import { Octokit } from "@octokit/rest";
import fs from "fs";
import { parseArgs, ParseArgsConfig } from "node:util";
import { join, resolve } from "path";
import { join } from "path";
import { LabelContext } from "./labelling-types.js";
import { PRContext } from "./PRContext.js";

export async function getRoot(inputPath: string): Promise<string> {
try {
const gitRoot = await getRootFolder(inputPath);
return resolve(gitRoot.trim());
return await getRootFolder(inputPath);
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

getRootFolder() already calls resolve() and trim().

} catch (error) {
console.error(
`Error: Unable to determine the root folder of the git repository.`,
Expand Down Expand Up @@ -130,19 +129,10 @@

let impact = await evaluateImpact(prContext, labelContext);

// sets by default are not serializable, so we need to convert them to arrays
// before we can write them to the output file.
function setReplacer(_key: string, value: any) {
if (value instanceof Set) {
return [...value];
}
return value;
}

console.log("Evaluated impact: ", JSON.stringify(impact, setReplacer, 2));
console.log("Evaluated impact: ", JSON.stringify(impact, null, 2));
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

impact is never a Set, so I think this is equivalent.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Agreed I removed the objects with sets.


// Write to a temp file that can get picked up later.
const summaryFile = join(process.cwd(), "summary.json");
fs.writeFileSync(summaryFile, JSON.stringify(impact, setReplacer, 2));
fs.writeFileSync(summaryFile, JSON.stringify(impact, null, 2));
setOutput("summary", summaryFile);
}
Loading