From e3bff8d95ae4a1bac12225c8df72a35300e8717e Mon Sep 17 00:00:00 2001 From: shishkevichd Date: Wed, 4 Sep 2024 19:23:54 +0700 Subject: [PATCH] chore: changing an array to an `Variables` object --- create-vite-express/src/main.ts | 2 +- create-vite-express/src/patches.ts | 10 +++++++--- 2 files changed, 8 insertions(+), 4 deletions(-) diff --git a/create-vite-express/src/main.ts b/create-vite-express/src/main.ts index f115ccf..986d217 100644 --- a/create-vite-express/src/main.ts +++ b/create-vite-express/src/main.ts @@ -37,7 +37,7 @@ export async function main({ const filePath = path.join(projectPath, patch); if (fs.existsSync(filePath)) { const content = fs.readFileSync(filePath, "utf-8"); - fs.writeFileSync(filePath, PATCHES[patch](content, [projectName])); + fs.writeFileSync(filePath, PATCHES[patch](content, { projectName })); } } diff --git a/create-vite-express/src/patches.ts b/create-vite-express/src/patches.ts index 0bcb3e6..945fee9 100644 --- a/create-vite-express/src/patches.ts +++ b/create-vite-express/src/patches.ts @@ -1,8 +1,12 @@ -export const PATCHES: Record) => string> = { - "package.json": (content: string, variables: Array) => { +type Variables = { + projectName?: string +} + +export const PATCHES: Record string> = { + "package.json": (content: string, variables: Variables) => { const json = JSON.parse(content); - json["name"] = variables[0] + json["name"] = variables.projectName if (process.platform === "win32") { json.scripts["start"] = json.scripts["start"].replace(