From 5f3870ee9b813222066eca96a281009b3672050e Mon Sep 17 00:00:00 2001 From: Kiina Date: Tue, 15 Oct 2024 12:50:10 +0200 Subject: [PATCH] Respect silent option by only logging errors --- index.ts | 6 ++++++ src/index.ts | 4 ---- 2 files changed, 6 insertions(+), 4 deletions(-) diff --git a/index.ts b/index.ts index 0605c191..2006ff18 100644 --- a/index.ts +++ b/index.ts @@ -53,6 +53,9 @@ const generateTemplatesCommand = defineCommand({ }, }, run: async ({ args }) => { + if (args.debug) consola.level = Number.MAX_SAFE_INTEGER; + if (args.silent) consola.level = 0; + await generateTemplates({ cleanOutput: args["clean-output"], httpClientType: args["http-client"], @@ -270,6 +273,9 @@ const generateCommand = defineCommand({ }, }, run: async ({ args }) => { + if (args.debug) consola.level = Number.MAX_SAFE_INTEGER; + if (args.silent) consola.level = 0; + let customConfig = null; let customConfigPath: string | undefined; diff --git a/src/index.ts b/src/index.ts index 6ef76c06..85477ac6 100644 --- a/src/index.ts +++ b/src/index.ts @@ -1,13 +1,9 @@ -import { consola } from "consola"; import type { GenerateApiConfiguration } from "../types/index.js"; import { CodeGenProcess } from "./code-gen-process.js"; export async function generateApi( config: Partial, ) { - if (config.debug) { - consola.level = Number.MAX_SAFE_INTEGER; - } const codeGenProcess = new CodeGenProcess(config); return await codeGenProcess.start(); }