diff --git a/package.json b/package.json index 546b0c1f83..5d571da2bf 100644 --- a/package.json +++ b/package.json @@ -79,6 +79,7 @@ "pretty-quick": "^3.1.0", "react": "^18.0.0", "react-dom": "^18.0.0", + "tree-kill": "^1.2.2", "typescript": "5.1.3" }, "volta": { diff --git a/packages/core/cli/src/commands/e2e.js b/packages/core/cli/src/commands/e2e.js index ee702a4467..06127a317b 100644 --- a/packages/core/cli/src/commands/e2e.js +++ b/packages/core/cli/src/commands/e2e.js @@ -4,6 +4,7 @@ const { execSync } = require('node:child_process'); const axios = require('axios'); const { pTest } = require('./p-test'); const os = require('os'); +const treeKill = require('tree-kill'); /** * 检查服务是否启动成功 @@ -91,6 +92,17 @@ async function runApp(options = {}) { run('nocobase', [process.env.APP_ENV === 'production' ? 'start' : 'dev'], options); } +process.on('SIGINT', async () => { + treeKill(process.pid, (error) => { + if (error) { + console.error(error); + } else { + console.log('所有子进程已被杀掉,应用程序即将退出'); + } + process.exit(); + }); +}); + const commonConfig = { stdio: 'inherit', }; @@ -150,6 +162,10 @@ module.exports = (cli) => { console.log('APP_BASE_URL:', process.env.APP_BASE_URL); } }); + process.on('SIGINT', () => { + console.log('SIGINT......'); + }); + e2e .command('test') .allowUnknownOption() diff --git a/yarn.lock b/yarn.lock index f6ac61e719..01a558f2cc 100644 --- a/yarn.lock +++ b/yarn.lock @@ -24424,7 +24424,7 @@ transformation-matrix@^2.11.1: tree-kill@^1.2.2: version "1.2.2" - resolved "https://registry.npmmirror.com/tree-kill/-/tree-kill-1.2.2.tgz#4ca09a9092c88b73a7cdc5e8a01b507b0790a0cc" + resolved "https://registry.yarnpkg.com/tree-kill/-/tree-kill-1.2.2.tgz#4ca09a9092c88b73a7cdc5e8a01b507b0790a0cc" integrity sha512-L0Orpi8qGpRG//Nd+H90vFB+3iHnue1zSSGmNOOCh1GLJ7rUKVwV2HvijphGQS2UmhUZewS9VgvxYIdgr+fG1A== trim-lines@^3.0.0: