问题
I have like 5 npm scripts and each of them need their own terminal because they runned in watch mode and write something in console.
Here is the scripts:
"server-build-dev": "cd ts/backend && npx tsc -w && npm run server-lint",
"server-run-dev": "pm2 flush && pm2 start --only server --env development && pm2 logs",
"server-lint": "cd ts/backend && esw -w --ext .ts",
"client-build-dev": "cd ts/configs && npx webpack --config client.webpack.dev.js"
I prefer split terminals to see everything that is happennig.
What i'm hoping is to run all this scripts with one command. So if i type "npm run all-dev" vscode will open 5 split powersells for we where in each will be runned it's own script.
Is it possible? Or maybe there is another way of handling this?
回答1:
See my answer here : Create multiple terminals and run commands in VSCode
I just changed to use the "workbench.action.terminal.splitInActiveWorkspace",
command instead of creating a new terminal for each command and it works nicely. The demo gif doesn't really capture how quickly and fluidly it works. Starting with no terminals open:
You would not be running an master npm script like npm run all-dev
but instead running a task that runs 4 npm scripts in 4 split terminals.
Same caveat as in the linked answer - interact with a terminal sometime after running the command - vscode freezes on me if I try to close the editors without opening one or opening a new one for example. Hopefully that bug will be fixed. Just hit the +
button first before you start deleting these split terminals and it never freezes on me.
来源:https://stackoverflow.com/questions/59229560/how-to-open-multiple-split-terminals-for-each-npm-script