我想使用运行which brownie
的输出作为launch.json
中"program"
的值。例如,在launch.json
的这个片段中
"configurations": [
{
"name": "Brownie: run deploy.js",
"type": "python",
"request": "launch",
"program": "/home/fanta/.local/virtualenv/python3.10/bin/brownie",
"console": "integratedTerminal",
"args": ["run", "scripts/deploy.js"]
},
我想用which brownie
的输出替换我硬连接的/home/fanta/.local/virtualenv/python3.10/bin/brownie
的完整路径。我该怎么做?
您可以设置一个执行which brownie
并将其写入临时文件的preLaunchTask
{
"version": "2.0.0",
"tasks": [
{
"label": "which brownie",
"type": "shell",
"command": "which brownie > /tmp/brownie-loc.txt"
}
]
}
使用扩展命令变量,您可以使用命令extension.commandvariable.file.content
来使用启动中的文件内容
{
"version": "0.2.0",
"configurations": [
{
"name": "Brownie: run deploy.js",
"type": "python",
"request": "launch",
"program": "${input:browniePath}",
"console": "integratedTerminal",
"args": ["run", "scripts/deploy.js"],
"preLaunchTask": "which brownie"
}
],
"inputs": [
{
"id": "browniePath",
"type": "command",
"command": "extension.commandvariable.file.content",
"args": {
"fileName": "/tmp/brownie-loc.txt"
}
}
]
}