Skip to content

Commit

Permalink
feat: telemetry and compareFrom removal (#605)
Browse files Browse the repository at this point in the history
* removed compareTo as we already expose the base flag.
* added Telemetry - off for non CI builds
  • Loading branch information
corneliu-petrescu authored Apr 3, 2024
1 parent fc5ccc8 commit 6e66314
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 14 deletions.
3 changes: 1 addition & 2 deletions src/__tests__/lint.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -42,13 +42,12 @@ describe("lint command", () => {
);

it(
"can lint with with --compare-to and --compare-from",
"can lint with with --compare-to",
async () => {
try {
process.chdir("end-end-tests/api-standards");
await lintAction(undefined, undefined, {
compareTo: "HEAD",
compareFrom: "main",
});
} catch (err) {
fail(err);
Expand Down
21 changes: 9 additions & 12 deletions src/lint.ts
Original file line number Diff line number Diff line change
Expand Up @@ -97,10 +97,9 @@ export const lintAction = async (
);
continue;
}
const base =
options?.compareFrom ??
linter["optic-ci"]?.original ??
defaultBranchName;

const base = linter["optic-ci"]?.original ?? defaultBranchName;

await expectGitBranch(base);
await bulkCompare(
path.join(path.relative(topDir, vervetConfDir), resource.path),
Expand All @@ -124,11 +123,6 @@ export const createLintCommand = () => {
"--compare-to <compare-to>",
"the head ref to compare against. Defaults to the current working directory",
)
.option(
"--compare-from <compare-from>",
"the base ref to compare against. Defaults to MAIN",
"main",
)
.action(lintAction);
command.description("lint APIs in current project");
return command;
Expand Down Expand Up @@ -161,10 +155,13 @@ const bulkCompare = async (
...extraArgs,
];
return new Promise<void>((resolve, reject) => {
const env = { ...process.env };
if (!process.env.CI) {
env.OPTIC_TELEMETRY_LEVEL = "off";
}

const child = child_process.spawn(process.argv0, args, {
env: {
...process.env,
},
env: env,
stdio: "inherit",
});
child.on("error", (err) => {
Expand Down

0 comments on commit 6e66314

Please sign in to comment.