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", "console": "integratedTerminal",
"internalConsoleOptions": "neverOpen" "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", "type": "node",
"request": "launch", "request": "launch",

View File

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