Don't insert empty line in rc file when it already ends with an empty line

This commit is contained in:
Sander Declerck 2026-01-27 07:42:36 +01:00
parent 8e966b0609
commit 309d7df050
No known key found for this signature in database

View file

@ -99,7 +99,7 @@ export const knownAikidoTools = [
aikidoCommand: "aikido-pipx", aikidoCommand: "aikido-pipx",
ecoSystem: ECOSYSTEM_PY, ecoSystem: ECOSYSTEM_PY,
internalPackageManagerName: "pipx", internalPackageManagerName: "pipx",
} },
// When adding a new tool here, also update the documentation for the new tool in the README.md // When adding a new tool here, also update the documentation for the new tool in the README.md
]; ];
@ -216,7 +216,13 @@ export function addLineToFile(filePath, line, eol) {
eol = eol || os.EOL; eol = eol || os.EOL;
const fileContent = fs.readFileSync(filePath, "utf-8"); const fileContent = fs.readFileSync(filePath, "utf-8");
const updatedContent = fileContent + eol + line + eol; let updatedContent = fileContent;
if (!fileContent.endsWith(eol)) {
updatedContent += eol;
}
updatedContent += line + eol;
fs.writeFileSync(filePath, updatedContent, "utf-8"); fs.writeFileSync(filePath, updatedContent, "utf-8");
} }