Skip to content

Commit cf7d67f

Browse files
authored
create the working dir if it doesn't exist (#147)
1 parent 47fa2fc commit cf7d67f

File tree

2 files changed

+6
-1
lines changed

2 files changed

+6
-1
lines changed

pkgs/dart_mcp_server/lib/src/utils/cli_utils.dart

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -214,9 +214,12 @@ Future<CallToolResult> runCommandInRoot(
214214
}
215215
commandWithPaths.addAll(paths);
216216

217+
final workingDir = fileSystem.directory(projectRoot.path);
218+
await workingDir.create(recursive: true);
219+
217220
final result = await processManager.run(
218221
commandWithPaths,
219-
workingDirectory: projectRoot.path,
222+
workingDirectory: workingDir.path,
220223
runInShell: true,
221224
);
222225

pkgs/dart_mcp_server/test/utils/cli_utils_test.dart

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -56,6 +56,7 @@ void main() {
5656
test(
5757
'can run commands with roots that are subdirectories of known roots',
5858
() async {
59+
expect(fileSystem.directory('/bar/baz').existsSync(), false);
5960
final result = await runCommandInRoots(
6061
CallToolRequest(
6162
name: 'foo',
@@ -79,6 +80,7 @@ void main() {
7980
workingDirectory: '/bar/baz/',
8081
)),
8182
]);
83+
expect(fileSystem.directory('/bar/baz').existsSync(), true);
8284
},
8385
);
8486
});

0 commit comments

Comments
 (0)