99
1010import java .io .BufferedReader ;
1111import java .io .BufferedWriter ;
12+ import java .io .File ;
1213import java .io .IOException ;
1314import java .io .InputStreamReader ;
1415import java .io .OutputStreamWriter ;
@@ -53,6 +54,11 @@ private StdioProxy(Builder builder) {
5354 processBuilder .environment ().putAll (builder .environmentVariables );
5455 }
5556
57+ // Set working directory if provided
58+ if (builder .workingDirectory != null ) {
59+ processBuilder .directory (builder .workingDirectory );
60+ }
61+
5662 this .name = builder .name ;
5763
5864 processBuilder .redirectErrorStream (false ); // Keep stderr separate
@@ -63,6 +69,7 @@ public static class Builder {
6369 private String name ;
6470 private List <String > arguments ;
6571 private Map <String , String > environmentVariables ;
72+ private File workingDirectory ;
6673
6774 public Builder name (String name ) {
6875 this .name = name ;
@@ -84,6 +91,11 @@ public Builder environmentVariables(Map<String, String> environmentVariables) {
8491 return this ;
8592 }
8693
94+ public Builder workingDirectory (File workingDirectory ) {
95+ this .workingDirectory = workingDirectory ;
96+ return this ;
97+ }
98+
8799 public StdioProxy build () {
88100 if (command == null || command .isEmpty ()) {
89101 throw new IllegalArgumentException ("Command must be provided" );
0 commit comments