Skip to content

Commit

Permalink
Support relative & absolute paths (#270)
Browse files Browse the repository at this point in the history
  • Loading branch information
lcampos authored Aug 2, 2024
1 parent 1b1324a commit eae701e
Showing 1 changed file with 9 additions and 4 deletions.
13 changes: 9 additions & 4 deletions packages/cli/src/sync-report/handler.ts
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ import {
printScoreSummary,
} from "../common/output.js";
import { existsSync } from "node:fs";
import { join, relative, resolve } from "node:path";
import { isAbsolute, join, relative, resolve } from "node:path";
import { ApiError } from "@zuplo/errors";
import { readFile } from "node:fs/promises";
import { lookup } from "mime-types";
Expand All @@ -32,9 +32,15 @@ export async function syncReport(argv: SyncReportArguments) {
printResultToConsoleAndExitGracefully("\nProcess has been canceled\n");
});

const sourceDirectory = resolve(join(relative(process.cwd(), argv.dir)));
const completePath =
argv.dir && argv.dir !== "."
? join(argv.dir, argv.filename)
: argv.filename;

const openApiFilePath = isAbsolute(completePath)
? completePath
: resolve(join(relative(process.cwd(), completePath)));

const openApiFilePath = join(sourceDirectory, argv.filename);
if (!existsSync(openApiFilePath)) {
spinner.stopAndPersist({ symbol: failMark });
printCriticalFailureToConsoleAndExit(
Expand Down Expand Up @@ -86,7 +92,6 @@ export async function syncReport(argv: SyncReportArguments) {

try {
res.results.fullReport.issues.forEach((issue) => {
console.log(`${openApiFilePath}`);
let issueType: "error" | "warning" | "info";
if (issue.severity === 0) {
totalErrors++;
Expand Down

0 comments on commit eae701e

Please sign in to comment.