@jjdenhertog/ai-driven-development
Version:
AI-driven development workflow with learning capabilities for Claude
24 lines • 1.15 kB
JavaScript
;
Object.defineProperty(exports, "__esModule", { value: true });
exports.addToGitignore = addToGitignore;
const node_fs_1 = require("node:fs");
const node_path_1 = require("node:path");
const logger_1 = require("../logger");
function addToGitignore(cwd, value, comment) {
const gitignorePath = (0, node_path_1.join)(cwd, '.gitignore');
const entryToAdd = value.endsWith('/') ? value : value;
if ((0, node_fs_1.existsSync)(gitignorePath)) {
const gitignoreContent = (0, node_fs_1.readFileSync)(gitignorePath, 'utf8');
if (!gitignoreContent.includes(entryToAdd)) {
const addition = comment ? `\n${comment}\n${entryToAdd}\n` : `\n${entryToAdd}\n`;
(0, node_fs_1.appendFileSync)(gitignorePath, addition);
(0, logger_1.log)(`Added ${value} to .gitignore`, 'success');
}
}
else {
const content = comment ? `${comment}\n${entryToAdd}\n` : `${entryToAdd}\n`;
(0, node_fs_1.writeFileSync)(gitignorePath, content);
(0, logger_1.log)(`Created .gitignore file and added ${value} to it`, 'success');
}
}
//# sourceMappingURL=addToGitignore.js.map