chore(vscode): add inspect argument for attaching to debug port (#3307)

This commit is contained in:
Junyi 2024-01-03 09:19:51 +08:00 committed by GitHub
parent 4dbac496be
commit e8b7fbd699
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 18 additions and 2 deletions

10
.vscode/launch.json vendored
View File

@ -11,6 +11,16 @@
"console": "integratedTerminal",
"internalConsoleOptions": "neverOpen"
},
{
"address": "localhost",
"localRoot": "${workspaceFolder}",
"name": "Attach to debug server (remote)",
"port": 9229,
"remoteRoot": "${workspaceFolder}",
"request": "attach",
"skipFiles": ["<node_internals>/**"],
"type": "node"
},
{
"type": "node",
"request": "launch",

View File

@ -15,6 +15,7 @@ module.exports = (cli) => {
.option('--client')
.option('--server')
.option('--db-sync')
.option('--inspect [port]')
.allowUnknownOption()
.action(async (opts) => {
promptForTs();
@ -33,7 +34,7 @@ module.exports = (cli) => {
return;
}
const { port, client, server } = opts;
const { port, client, server, inspect } = opts;
if (port) {
process.env.APP_PORT = opts.port;
@ -59,8 +60,13 @@ module.exports = (cli) => {
if (server || !client) {
console.log('starting server', serverPort);
const filteredArgs = process.argv.filter(
(item, i) => !item.startsWith('--inspect') && !(process.argv[i - 1] === '--inspect' && Number.parseInt(item)),
);
const argv = [
'watch',
...(inspect ? [`--inspect=${inspect === true ? 9229 : inspect}`] : []),
'--ignore=./storage/plugins/**',
'--tsconfig',
SERVER_TSCONFIG_PATH,
@ -68,7 +74,7 @@ module.exports = (cli) => {
'tsconfig-paths/register',
`${APP_PACKAGE_ROOT}/src/index.ts`,
'start',
...process.argv.slice(3),
...filteredArgs.slice(3),
`--port=${serverPort}`,
];