如何在 setAction() 中将 VSCode 调试器附加到安全帽任务的回调,以便断点起作用?



我想我的代码执行暂停在setActions内部的动作回调的一些表达式。当我运行下面的配置和断点时,调试器会立即运行并退出,而不会在断点处停止。

// Filename : DoSomething.js
task("DoSomething", "DoesSomething")
.addParam("account", "The account's address")
.setAction(async () => {
// breakpoint somewhere here!

});

我的发射。Json配置如下:

"configurations": [
{
"type": "node",
"request": "launch",
"name": "Debug Do Something",
"skipFiles": [
"<node_internals>/**"
],
"program": "${workspaceFolder}/tasks/admin/DoSomething.js",
"runtimeExecutable": "${workspaceFolder}/node_modules/.bin/hardhat",
"runtimeArgs":["--network", "goerli", "--account", "0xMyAddress1234555....."]
}
]

我猜这个动作在hardhat的内部注册,并作为一个副本传递,所以也许那行不直接执行?真的很想知道这里发生了什么!

我已经能够在VSCode的调试器中使用这个Auto Attach开关[1]来实现调试硬帽任务的有用进展。

[1] https://code.visualstudio.com/docs/nodejs/nodejs-debugging _auto-attach