Debuggning Probot with Visual Studio Code
One of the Zalando Open Source Teams responsibilities is to ensure that our use of Github is Compliant and accesible to our engineering teams. One way to ensure this is to build tooling and automation which supports our compliance rules.
Probot is an excellent framework for building Github bots, but it’s been challenging to figure our how to monitor activities in the bot and debug it with VS codes breakpoints. Out of the box Probot uses nodemon, which gives me a decent output to the terminal, but it feels like going back in time to
console.log based development
Configuring VSCode for debugging
Luckily the probot typescript template comes with a good starting point, after going through the wizard I configured a new Typescript compile task in
I then used this task with an entry in the
.vscode/launch.json config to ensure Typescript is compiled before the debugger is attached:
Notice the prelaunch task is my Typescript compiler and that I use
probot-run.js from the Probot module to run
./lib/index.js the index.js is the output of my typescript compile, based on the include .tsconfig file.
Debugging with breakpoints
With the combination of a compile task and a launch setting I can now simply hit F5 and the probot will start up locally, receive webhooks from Github through smee.io and any breakpoints set in VS Code will be hit with access to variables and all the other debugging goodness.