Skip to content

Commit

Permalink
fix: update cli and loader with ignoreDefaults
Browse files Browse the repository at this point in the history
  • Loading branch information
paulohsa-miele authored and paulohsa32 committed Apr 14, 2023
1 parent 2a6f11f commit dd91177
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 7 deletions.
4 changes: 3 additions & 1 deletion src/cli.ts
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,9 @@ async function main() {
}

const { loadSchema } = await import("./loader/loader");
const schema = await loadSchema(entryPath, { inferDefaults: args.defaults });
const schema = await loadSchema(entryPath, {
ignoreDefaults: args.ignoreDefaults,
});
if (args.write) {
const json = JSON.stringify(schema, null, 2);
const outfile = resolve(
Expand Down
10 changes: 4 additions & 6 deletions src/loader/loader.ts
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ type JITIOptions = Parameters<typeof jiti>[1];
export interface LoaderOptions {
jiti?: JITIOptions;
defaults?: Record<string, any>;
inferDefaults?: boolean;
ignoreDefaults?: boolean;
}

export async function loadSchema(
Expand All @@ -32,11 +32,9 @@ export async function loadSchema(

const resolvedEntryPath = _jitiRequire.resolve(entryPath);
const rawSchema = _jitiRequire(resolvedEntryPath);
const schema = await resolveSchema(
rawSchema,
options.defaults,
options.inferDefaults
);
const schema = await resolveSchema(rawSchema, options.defaults, {
ignoreDefaults: options.ignoreDefaults,
});

return schema;
}

0 comments on commit dd91177

Please sign in to comment.