Skip to content

Commit ca7acb0

Browse files
committed
fix: make logFile optional in config
1 parent 097d0a1 commit ca7acb0

File tree

5 files changed

+10
-8
lines changed

5 files changed

+10
-8
lines changed

packages/openapi-ts/bin/index.cjs

+2
Original file line numberDiff line numberDiff line change
@@ -118,6 +118,8 @@ async function start() {
118118
userConfig.logs.level = 'silent';
119119
}
120120

121+
userConfig.logs.file = userConfig.logFile;
122+
121123
if (typeof params.watch === 'string') {
122124
userConfig.watch = Number.parseInt(params.watch, 10);
123125
}

packages/openapi-ts/src/getLogs.ts

+1
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@ import type { Config, UserConfig } from './types/config';
22

33
export const getLogs = (userConfig: UserConfig | undefined): Config['logs'] => {
44
let logs: Config['logs'] = {
5+
file: true,
56
level: 'info',
67
path: process.cwd(),
78
};

packages/openapi-ts/src/index.ts

+2-2
Original file line numberDiff line numberDiff line change
@@ -67,11 +67,11 @@ export const createClient = async (
6767
} catch (error) {
6868
const config = configs[0] as Config | undefined;
6969
const dryRun = config ? config.dryRun : resolvedConfig?.dryRun;
70-
const writeLogFile = config ? config.logFile : resolvedConfig?.logFile;
70+
7171
// TODO: add setting for log output
7272
if (!dryRun) {
7373
const logs = config?.logs ?? getLogs(resolvedConfig);
74-
if (logs.level !== 'silent' && writeLogFile) {
74+
if (logs.level !== 'silent' && logs.file) {
7575
const logName = `openapi-ts-error-${Date.now()}.log`;
7676
const logsDir = path.resolve(process.cwd(), logs.path ?? '');
7777
ensureDirSync(logsDir);

packages/openapi-ts/src/initConfigs.ts

-2
Original file line numberDiff line numberDiff line change
@@ -269,7 +269,6 @@ export const initConfigs = async (
269269
dryRun = false,
270270
experimentalParser = true,
271271
exportCore = true,
272-
logFile = true,
273272
name,
274273
request,
275274
useOptions = true,
@@ -312,7 +311,6 @@ export const initConfigs = async (
312311
experimentalParser,
313312
exportCore: false,
314313
input,
315-
logFile,
316314
logs,
317315
name,
318316
output,

packages/openapi-ts/src/types/config.d.ts

+5-4
Original file line numberDiff line numberDiff line change
@@ -160,6 +160,10 @@ export interface UserConfig {
160160
logs?:
161161
| string
162162
| {
163+
/**
164+
* Whether or not error logs should be written to a file or not
165+
* */
166+
file?: boolean;
163167
/**
164168
* The logging level to control the verbosity of log output.
165169
* Determines which messages are logged based on their severity.
@@ -185,17 +189,14 @@ export interface UserConfig {
185189
| 'silent'
186190
| 'trace'
187191
| 'warn';
192+
188193
/**
189194
* The relative location of the logs folder
190195
*
191196
* @default process.cwd()
192197
*/
193198
path?: string;
194199
};
195-
/**
196-
* Whether or not error logs should be written to a file or not
197-
* */
198-
logFile: boolean;
199200
/**
200201
* Regenerate the client when the input file changes? You can alternatively
201202
* pass a numeric value for the interval in ms.

0 commit comments

Comments
 (0)