UNPKG

refakts

Version:

TypeScript refactoring tool built for AI coding agents to perform precise refactoring operations via command line instead of requiring complete code regeneration.

26 lines 1.14 kB
"use strict"; Object.defineProperty(exports, "__esModule", { value: true }); exports.SectionReplacer = void 0; class SectionReplacer { replaceSection(content, startMarker, endMarker, newContent) { const markerPositions = this.findMarkerPositions(content, startMarker, endMarker); if (markerPositions.startIndex === -1 || markerPositions.endIndex === -1) { process.stderr.write(`Warning: Markers ${startMarker}/${endMarker} not found\n`); return content; } return this.buildReplacementContent(content, markerPositions, startMarker, newContent); } findMarkerPositions(content, startMarker, endMarker) { return { startIndex: content.indexOf(startMarker), endIndex: content.indexOf(endMarker) }; } buildReplacementContent(content, positions, startMarker, newContent) { return content.substring(0, positions.startIndex) + startMarker + '\n' + newContent + '\n' + content.substring(positions.endIndex); } } exports.SectionReplacer = SectionReplacer; //# sourceMappingURL=SectionReplacer.js.map