Skip to content

Commit

Permalink
chore: changing an array to an Variables object
Browse files Browse the repository at this point in the history
  • Loading branch information
shishkevichd committed Sep 4, 2024
1 parent 74ad182 commit e3bff8d
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 4 deletions.
2 changes: 1 addition & 1 deletion create-vite-express/src/main.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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 }));
}
}

Expand Down
10 changes: 7 additions & 3 deletions create-vite-express/src/patches.ts
Original file line number Diff line number Diff line change
@@ -1,8 +1,12 @@
export const PATCHES: Record<string, (content: string, variables: Array<String>) => string> = {
"package.json": (content: string, variables: Array<String>) => {
type Variables = {
projectName?: string
}

export const PATCHES: Record<string, (content: string, variables: Variables) => 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(
Expand Down

0 comments on commit e3bff8d

Please sign in to comment.