nop*_*rt1 10 node.js docker visual-studio-code vscode-settings vscode-tasks
我有一个 monorepo,我希望在其中创建一个脚本以在本地启动特定项目。
该项目是完全Node.js
基于。
为了在本地设置此项目进行开发,我需要按以下顺序运行以下命令:
启动 docker 镜像
cd docker/dockerForTests
docker-compose up -d
启动 Web Auth 服务器
cd src/project/webAuthentication
setenvs projectAuthentication && npm start
启动 API
cd src/project/api
setenvs projectAPI && npm start
启动网络客户端
cd src/project/web
setenvs projectWeb && npm start
为了便于使用,我通常在 VSCode 内的新终端窗口中启动每个部分。
为了自动化这个过程,我发现了 VSCode 任务。
虽然看起来它们是为“构建”或“观察”任务而设计的,但我认为我可以修改行为来为我运行上述命令。
这是我的尝试:
{
// See https://go.microsoft.com/fwlink/?LinkId=733558
// for the documentation about the tasks.json format
"runner": "terminal",
"version": "2.0.0",
"tasks": [
{
"label": "Start Docker",
"dependsOrder": "sequence",
"type": "shell",
"command": "cd docker/dockerForTests && docker-compose up -d",
},
{
"label": "Start Web Auth",
"dependsOrder": "sequence",
"type": "process",
"command": "cd src/project/webAuthentication && setenvs projectAuthentiction && npm start"
},
{
"label": "Start Up Local Development Environment",
"presentation": {
"echo": true,
"reveal": "always",
"focus": true,
"panel": "new",
"showReuseMessage": false,
"clear": true
},
"dependsOn": [
"Start Docker",
"Start Web Auth"
],
"problemMatcher": []
}
]
}
Run Code Online (Sandbox Code Playgroud)
第一个命令工作正常,但我希望它像集成终端一样,一旦命令完成运行,它就会挂起以供输入。
其次,第二个任务不起作用,因为它不是 Node 命令。
我希望它像常规的 bash 输入一样工作。
如何自动化上述工作流程?甚至有可能吗?
至少第 2、3 和 4 点同时工作得很好,并且对于第 1 点也应该工作得很好。通过根目录中 package.json 部分中的以下脚本,scripts
您应该只需一个命令即可启动您的开发环境
"start-docker": "cd docker/dockerForTests && docker-compose up -d",
"start-auth": "cd src/project/webAuthentication && setenvs projectAuthentication && npm start",
"start-api": "cd src/project/api && setenvs projectAPI && npm start",
"start-client": "cd src/project/web && setenvs projectWeb && npm start",
"start-dev": "concurrently \"npm run start-docker\" \"npm run start-auth\" \"npm run start-api\" \"npm run start-client\""
Run Code Online (Sandbox Code Playgroud)
这不使用 VSCode 任务,但无论如何都会简化你的生活。
归档时间: |
|
查看次数: |
414 次 |
最近记录: |