-
Notifications
You must be signed in to change notification settings - Fork 45
Expand file tree
/
Copy pathadapter.lua
More file actions
51 lines (42 loc) · 1.38 KB
/
adapter.lua
File metadata and controls
51 lines (42 loc) · 1.38 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
local M = {}
local utils = require("dap-vscode-js.utils")
-- local logger = require("dap-vscode-js.log")
local dapjs_config = require("dap-vscode-js.config")
function M.generate_adapter(_, user_config)
user_config = user_config or dapjs_config
return function(on_config, config, parent)
local target = config["__pendingTargetId"]
if target and parent then
local adapter = parent.adapter
on_config({
type = "server",
host = "localhost",
port = adapter.port
})
else
local debug_executable = user_config.adapter_executable_config
if not debug_executable then
local debugger_path = user_config.debugger_executable
if not utils.file_exists(debugger_path) then
-- TODO: show user to README.md with directions
error("Debugger entrypoint file '" .. debugger_path .. "' does not exist. Did it build properly?")
end
local debugger_cmd_args = { debugger_path, "${port}" }
for _, arg in ipairs(user_config.debugger_args or {}) do
table.insert(debugger_cmd_args, arg)
end
debug_executable = {
command = user_config.node_path,
args = debugger_cmd_args,
}
end
on_config({
type = "server",
host = "localhost",
port = "${port}",
executable = debug_executable
})
end
end
end
return M