core: fix jest not exiting

This commit is contained in:
undefined committed 2021-04-03 03:24:25 +08:00
1 parent 49ec3c216f
commit b9fdf3bca9
2 files changed
+8 -5

No files matched your search

+2 -2
View File
@@ -38,10 +38,10 @@ class MongoService implements BaseService {
}
public async stop() {
await this.db.close();
await this.db2.close();
await this.client.close();
await this.client2.close();
await this.db.close();
await this.db2.close();
}
}
+6 -3
View File
@@ -6,7 +6,8 @@ import { Logger } from './logger';
import * as bus from './service/bus';
const logger = new Logger('ui');
const useTerminal = cluster.isMaster && process.stdout.isTTY && !argv.legacy && !argv._.length;
const useTerminal = cluster.isMaster && process.stdout.isTTY;
const disabledTerminal = argv.legacy || argv._.length || process.env.NODE_ENV === 'test';
export namespace Progress {
export class Progress {
@@ -43,7 +44,7 @@ async function terminate() {
}
process.on('SIGINT', terminate);
if (useTerminal) {
if (useTerminal && !disabledTerminal) {
let current = 0;
const history = [''];
let input = '';
@@ -81,10 +82,11 @@ if (useTerminal) {
logger.warn('Running over ssh detected. Add a --legacy when starting if GUI mode doesn\'t work properly.');
}
} else if (cluster.isMaster) {
console.log('Not running in a terminal environment. Interactive mode disabled.');
if (!disabledTerminal) console.log('Not running in a terminal environment. Interactive mode disabled.');
bus.on('message/log', (message) => {
process.stdout.write(`${message}\n`);
});
if (process.env.NODE_ENV !== 'test') {
process.stdin.setEncoding('utf-8');
process.stdin.on('data', (buf) => {
const input = buf.toString();
@@ -96,3 +98,4 @@ if (useTerminal) {
} else bus.parallel('message/run', input);
});
}
}