Skip to content

Commit

Permalink
fix: using relative to compare paths
Browse files Browse the repository at this point in the history
  • Loading branch information
tvillaren committed Dec 8, 2023
1 parent 5ca20fa commit 4f2d581
Showing 1 changed file with 5 additions and 2 deletions.
7 changes: 5 additions & 2 deletions src/core/generate.ts
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@ import {
generateZodSchemaVariableStatementForClass,
} from "./generateZodSchema";
import { transformRecursiveSchema } from "./transformRecursiveSchema";
import { relative } from "path";

const DEFAULT_GET_SCHEMA = (id: string) => camel(id) + "Schema";

Expand Down Expand Up @@ -107,10 +108,12 @@ export function generate({
}
if (ts.isImportDeclaration(node) && node.importClause) {
// Check if we're importing from a mapped file

const eligibleMapping = inputOutputMappings.find(
(io: InputOutputMapping) =>
io.input === (node.moduleSpecifier as ts.StringLiteral).text
relative(
io.input,
(node.moduleSpecifier as ts.StringLiteral).text
) === ""
);
if (eligibleMapping) {
const schemaMethod =
Expand Down

0 comments on commit 4f2d581

Please sign in to comment.