Skip to content

Commit 43830f4

Browse files
adwsinghrhernandez35
authored andcommitted
Instead of rewriting all lines, just append
1 parent 4b1ae3d commit 43830f4

File tree

1 file changed

+6
-5
lines changed
  • mcp/mcp-cli-api/src/main/java/software/amazon/smithy/java/mcp/cli

1 file changed

+6
-5
lines changed

mcp/mcp-cli-api/src/main/java/software/amazon/smithy/java/mcp/cli/ConfigUtils.java

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -452,15 +452,16 @@ private static boolean tryAddToShellConfigs(String shimsDirStr) {
452452

453453
if (!alreadyPresent) {
454454
// Add the export statement
455-
lines.add("");
456-
lines.add(comment);
457-
lines.add(pathExport);
455+
var newLines = new ArrayList<String>();
456+
newLines.add("");
457+
newLines.add(comment);
458+
newLines.add(pathExport);
458459

459460
Files.write(configPath,
460-
lines,
461+
newLines,
461462
StandardCharsets.UTF_8,
462463
StandardOpenOption.WRITE,
463-
StandardOpenOption.TRUNCATE_EXISTING);
464+
StandardOpenOption.APPEND);
464465

465466
System.out.println("Added mcp-servers directory to PATH in " + configFile);
466467
System.out.println(

0 commit comments

Comments
 (0)