fix: .gitignore missing trailing newline during project initialization (#855)

This commit is contained in:
Joe Danziger
2025-06-24 00:42:23 -04:00
committed by GitHub
parent 295087a5b8
commit e4456b11bc
3 changed files with 13 additions and 5 deletions

View File

@@ -0,0 +1,5 @@
---
"task-master-ai": patch
---
Fix .gitignore missing trailing newline during project initialization

View File

@@ -170,7 +170,7 @@ function validateInputs(targetPath, content, storeTasksInGit) {
*/
function createNewGitignoreFile(targetPath, templateLines, log) {
try {
fs.writeFileSync(targetPath, templateLines.join('\n'));
fs.writeFileSync(targetPath, templateLines.join('\n') + '\n');
if (typeof log === 'function') {
log('success', `Created ${targetPath} with full template`);
}
@@ -223,7 +223,7 @@ function mergeWithExistingFile(
finalLines.push(...buildTaskFilesSection(storeTasksInGit));
// Write result
fs.writeFileSync(targetPath, finalLines.join('\n'));
fs.writeFileSync(targetPath, finalLines.join('\n') + '\n');
if (typeof log === 'function') {
const hasNewContent =

View File

@@ -179,7 +179,8 @@ logs
# Task files
# tasks.json
# tasks/ `
# tasks/
`
);
expect(mockLog).toHaveBeenCalledWith(
'success',
@@ -200,7 +201,8 @@ logs
# Task files
tasks.json
tasks/ `
tasks/
`
);
expect(mockLog).toHaveBeenCalledWith(
'success',
@@ -432,7 +434,8 @@ tasks/ `;
const writtenContent = writeFileSyncSpy.mock.calls[0][1];
expect(writtenContent).toBe(`# Task files
# tasks.json
# tasks/ `);
# tasks/
`);
});
});
});