fix: e2e test did not exit successfully (#3427)

* fix: e2e test did not exit successfully

* fix: tree kill

---------

Co-authored-by: dream2023 <1098626505@qq.com>
This commit is contained in:
chenos 2024-01-24 14:55:41 +08:00 committed by GitHub
parent 1b2c67fea7
commit 2792cb1b0a
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
3 changed files with 18 additions and 1 deletions

View File

@ -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": {

View File

@ -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()

View File

@ -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: