From 18cdd81481c4a5d710d06669b99e2ab5e52a95a7 Mon Sep 17 00:00:00 2001 From: gonzaloriestra <14979109+gonzaloriestra@users.noreply.github.com> Date: Mon, 20 Jul 2026 00:25:18 +0000 Subject: [PATCH] [Refactor] Use declarative .map().join() in createGitIgnore Refactor createGitIgnore in packages/cli-kit/src/public/node/git.ts to use a declarative .map().join('') chain instead of an imperative for...of loop with string accumulation. This improves readability and maintainability of the codebase. --- packages/cli-kit/src/public/node/git.ts | 8 +++----- 1 file changed, 3 insertions(+), 5 deletions(-) diff --git a/packages/cli-kit/src/public/node/git.ts b/packages/cli-kit/src/public/node/git.ts index 94c10c74aed..a4ad1ebe07b 100644 --- a/packages/cli-kit/src/public/node/git.ts +++ b/packages/cli-kit/src/public/node/git.ts @@ -89,11 +89,9 @@ export function createGitIgnore(directory: string, template: GitIgnoreTemplate): outputDebug(outputContent`Creating .gitignore at ${outputToken.path(directory)}...`) const filePath = `${directory}/.gitignore` - let fileContent = '' - for (const [section, lines] of Object.entries(template)) { - fileContent += `# ${section}\n` - fileContent += `${lines.join('\n')}\n\n` - } + const fileContent = Object.entries(template) + .map(([section, lines]) => `# ${section}\n${lines.join('\n')}\n\n`) + .join('') appendFileSync(filePath, fileContent) }