branch: externals/dape
commit d1a96de51cbee7c410d1f2680f860d09048e2fc5
Author: Artur <5359825+sethid...@users.noreply.github.com>
Commit: GitHub <nore...@github.com>

    Add "attach to already running Node process" js config (#80)
    
    Pre-defined configurations existing before this commit are meant
    to *launch* a program and simultaneously debug it.
    
    When I debug Node, I prefer to debug a little differently.
    I launch Node somewhere else (e.g. in a terminal emulator), like `node
    --inspect [program]` or `node --inspect-brk [program]`. Or even
    simpler: `node --inspect-brk -e "const x = 5; console.log(x);"`
    
    Then I attach to the already running process using my preferred DAP
    client (dape, vscode, chrome devtools etc.)
    
    In this case, you'd need to run M-x dape js-debug-node-attach
    
    Because in Node `--inspect` by default starts debugging on port 9229,
    the default for the new debug configuration is also 9229.
    
    However, if you prefer to use a different port, you can just do `M-x
    dape` and write `js-debug-node-attach :port 9030` in the minibuffer.
    
    Copyright-paperwork-exempt: yes
---
 dape.el | 6 ++++++
 1 file changed, 6 insertions(+)

diff --git a/dape.el b/dape.el
index cc05768175..1badb80b12 100644
--- a/dape.el
+++ b/dape.el
@@ -246,6 +246,12 @@
            :cwd dape-cwd
            :program dape-buffer-default
            :console "internalConsole")
+         (js-debug-node-attach
+           modes (js-mode js-ts-mode typescript-mode typescript-ts-mode)
+           ,@js-debug
+           :type "pwa-node"
+          :request "attach"
+          :port 9229)
           (js-debug-chrome
            modes (js-mode js-ts-mode typescript-mode typescript-ts-mode)
            ,@js-debug

Reply via email to