Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

How to debug using vscode debugger? #608

Open
MarceloBritoWD opened this issue Sep 29, 2019 · 7 comments
Open

How to debug using vscode debugger? #608

MarceloBritoWD opened this issue Sep 29, 2019 · 7 comments

Comments

@MarceloBritoWD
Copy link

It has a way to debug my cli using vscode or something like that? I didn't find any information about it.

@jamonholmgren
Copy link
Member

Hi @MarceloBritoWD!

I should write up a debugging guide, that's a great idea.

Is there something in particular you're having trouble debugging?

@MarceloBritoWD
Copy link
Author

Hi @jamonholmgren, thank you for answering me.

I already solve the problem and was a bug that I had created, but I missed a way to debug my cli app, so basically found the solution with console.log haha

@jamonholmgren
Copy link
Member

console.log works pretty well, to be honest. I also like toolbox.print.debug() which is built in to Gluegun's toolbox.

I'll work on this when I'm back from my Florida conference.

@phhoef
Copy link

phhoef commented Sep 15, 2021

Hi @jamonholmgren,

may I ask, if you found the time to write some docs about debugging?
I am struggling to get the debugger work properly.

I've started a new project following your docs by issuing npx gluegun new movies.
I added a new command and I see it is called - everything fine so far.
Now, before I start writing real functionality, I tried to setup the debugger with VScode.

I added a launch.json with the following configuration:

  "configurations": [
    {
      "type": "node",
      "request": "launch",
      "name": "Launch Program",
      "skipFiles": ["<node_internals>/**"],
      "program": "${workspaceFolder}/bin/my-project",
      "preLaunchTask": "tsc: build - tsconfig.json",
      "sourceMaps": true,
      "smartStep": true,
      "internalConsoleOptions": "openOnSessionStart",
      "outFiles": ["${workspaceFolder}/build/**/*.js"],
    }

The app gets compiled and the debugger will be attached, but unfortunately it is debugging the compiled js files.
I am quite new to typescript and glue gun ... Could you please guide me through?

@sawyerit
Copy link

For anyone else that comes across this, I was able to get debugging working by adding a call to the run() function at the end of the entry TS file (default generated file is cli.ts). The launch configurations program value should be the entry TS file (not the executable script in the bin folder). In my case I also needed to accept user input from the terminal so I also added the console configuration value.

    "configurations": [
        {
            "type": "pwa-node",
            "request": "launch",
            "name": "Launch Program",
            "skipFiles": [
                "<node_internals>/**"
            ],
            "program": "${workspaceFolder}/src/cli.ts",
            "preLaunchTask": "tsc: build - tsconfig.json",
            "sourceMaps": true,
            "smartStep": true,
            "console": "integratedTerminal",
            "outFiles": [
                "${workspaceFolder}/build/**/*.js"
            ]
        }
    ]

@jamonholmgren
Copy link
Member

Would definitely like to add more of this sort of guide to the docs. Thanks for the help @sawyerit.

@ElonVolo
Copy link
Contributor

@jamonholmgren Have you considered the possibility of generating a launch.json that's included with the project when its generated, so people wouldn't have to do any trial and error, hunting on the internet, or reading of docs?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

5 participants