diff --git a/package.json b/package.json index eaebb00..e10a25e 100644 --- a/package.json +++ b/package.json @@ -71,6 +71,16 @@ "description": "full path to executable.", "default": "${workspaceFolder}/bin/yourExecutable.exe" }, + "cwd": { + "type": "string", + "description": "working directory for the executable", + "default": "${workspaceFolder}" + }, + "args": { + "type": "array", + "description": "arguments for the executable", + "default": [] + }, "receiveAdapterOutput": { "type": "boolean", "description": "redirect adapter log to debug console", diff --git a/src/Adapter.hx b/src/Adapter.hx index 0218cb1..c464b8d 100644 --- a/src/Adapter.hx +++ b/src/Adapter.hx @@ -12,6 +12,8 @@ import hxcpp.debug.jsonrpc.Protocol; typedef HxppLaunchRequestArguments = LaunchRequestArguments & { var program:String; + var ?cwd:String; + var ?args:Array; } @:keep @@ -52,6 +54,8 @@ class Adapter extends DebugSession { override function launchRequest(response:LaunchResponse, args:LaunchRequestArguments) { var args:HxppLaunchRequestArguments = cast args; var executable = args.program; + var arguments = args.args; + var cwd = args.cwd; function onConnected(socket) { trace("Debug server connected!"); @@ -72,8 +76,8 @@ class Adapter extends DebugSession { var server = Net.createServer(onConnected); server.listen(6972, function() { - var args = []; - var haxeProcess = ChildProcess.spawn(executable, args, {stdio: Pipe, cwd: haxe.io.Path.directory(executable)}); + var haxeProcess = ChildProcess.spawn(executable, arguments != null ? arguments : [], + {stdio: Pipe, cwd: cwd != null ? cwd : haxe.io.Path.directory(executable)}); haxeProcess.stdout.on(ReadableEvent.Data, onStdout); haxeProcess.stderr.on(ReadableEvent.Data, onStderr); haxeProcess.on(ChildProcessEvent.Exit, onExit);