Skip to content
This repository was archived by the owner on Sep 27, 2024. It is now read-only.

Commit 0b5ab03

Browse files
committed
add output argument
1 parent 6e5b53f commit 0b5ab03

File tree

2 files changed

+6
-2
lines changed

2 files changed

+6
-2
lines changed

src/core/interface.ts

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@ import fs from "node:fs/promises";
22
import path from "node:path";
33
import Handlebars from "handlebars";
44
import interfaceTemplate from "~/templates/interface.hbs";
5+
import getArgument from "./arguments";
56
import type { OperationTemplate } from "./operation";
67

78
type InterfaceTemplate = {
@@ -20,7 +21,8 @@ export function generateInterface(baseUrl: string, schemas: string[], operations
2021
}
2122

2223
export async function saveInterface(name: string, content: string) {
23-
const interfacesFolder = path.resolve(process.cwd(), "src");
24+
const outputDir = await getArgument("output") ?? "src";
25+
const interfacesFolder = path.resolve(process.cwd(), outputDir);
2426
await fs.mkdir(interfacesFolder, { recursive: true });
2527
const filePath = path.resolve(interfacesFolder, `${name}.ts`);
2628
await fs.writeFile(filePath, content);

src/core/schema.ts

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@ import fs from "node:fs/promises";
22
import path from "node:path";
33
import Handlebars from "handlebars";
44
import schemaTemplate from "~/templates/schema.hbs";
5+
import getArgument from "./arguments";
56
import { resolveSchema } from "./schema-definition";
67
import type { SchemaDefinition } from "./openapi";
78

@@ -41,7 +42,8 @@ export function resolveProperties(collection: Record<string, SchemaDefinition>,
4142
}
4243

4344
export async function saveSchema(name: string, content: string) {
44-
const schemasFolder = path.resolve(process.cwd(), "src", "schemas");
45+
const outputDir = await getArgument("output") ?? "src";
46+
const schemasFolder = path.resolve(process.cwd(), outputDir, "schemas");
4547
await fs.mkdir(schemasFolder, { recursive: true });
4648
const filePath = path.resolve(schemasFolder, `${name}.ts`);
4749
await fs.writeFile(filePath, content);

0 commit comments

Comments
 (0)