1.2.0 • Published 5 years ago
debugbot v1.2.0
Debug Bot
This is a simple Node.js program which can attach to a running Node.js program and evaluate expressions and give you the value.
Setup Instructions
Install yarn if not installed already.
npm install -g yarn$ yarn install
$ yarn run build
$ yarn run testThis package uses Yarn 2.
node_modulesfolder is no more. It comes with a few extra initial setup steps. VS Code is supported.
- Make sure you select the 'Workspace version' of TypeScript.
- A recommended extension ZipFS could be installed optionally for debugging dependencies.
vscode-chrome-debug-coreis already 'unplug'ged
Usage
- Logic for using Debug Adapter is in Attacher
- InlineExpressionEvaluator is used for the below example. An expression can be evaluated in a line in a file.
- ExpressionEvaluator has a callback which is used when a breakpoint is hit and an expression is evaluated.
- An instance of InlineExpressionEvaluator class can be created.
attachmethod is used to attach to a running node.js process. The debugging port has to be passed as a parameter.getValuemethod is where a breakpoint is set and the value is fetched and returned. This needs the file path of the program where the breakpoint has to be set, line number, expression(variable name), and optionally column number.disconnectcan be used to disconnect the debugger.
Examples
tests/attacher.test.tshas the tests which is ran duringnpm run testtests/ExpressionEvaluator/inlineEvaluatorTest.tshas a simple program which can be used as an example, shown below.
In a terminal, run :
$ yarn node --inspect=43210 ./dist/tests/sampleProgram.jsOpen another terminal, run :
$ yarn node ./dist/tests/ExpressionEvaluator/inlineEvaluatorTest.jsYou can see that the value is printed on the console.