From 8ef9457fdee7812b1a8cc3b3bdeff94130819003 Mon Sep 17 00:00:00 2001 From: Chocobozzz Date: Tue, 6 Jul 2021 10:36:54 +0200 Subject: Correctly export misc files --- shared/extra-utils/miscs/email.ts | 64 --------------------------------------- shared/extra-utils/miscs/index.ts | 3 ++ 2 files changed, 3 insertions(+), 64 deletions(-) delete mode 100644 shared/extra-utils/miscs/email.ts create mode 100644 shared/extra-utils/miscs/index.ts (limited to 'shared/extra-utils/miscs') diff --git a/shared/extra-utils/miscs/email.ts b/shared/extra-utils/miscs/email.ts deleted file mode 100644 index 9fc9a5ad0..000000000 --- a/shared/extra-utils/miscs/email.ts +++ /dev/null @@ -1,64 +0,0 @@ -import { ChildProcess } from 'child_process' -import { randomInt } from '../../core-utils/miscs/miscs' -import { parallelTests } from '../server/servers' - -const MailDev = require('maildev') - -class MockSmtpServer { - - private static instance: MockSmtpServer - private started = false - private emailChildProcess: ChildProcess - private emails: object[] - - private constructor () { } - - collectEmails (emailsCollection: object[]) { - return new Promise((res, rej) => { - const port = parallelTests() ? randomInt(1000, 2000) : 1025 - this.emails = emailsCollection - - if (this.started) { - return res(undefined) - } - - const maildev = new MailDev({ - ip: '127.0.0.1', - smtp: port, - disableWeb: true, - silent: true - }) - - maildev.on('new', email => { - this.emails.push(email) - }) - - maildev.listen(err => { - if (err) return rej(err) - - this.started = true - - return res(port) - }) - }) - } - - kill () { - if (!this.emailChildProcess) return - - process.kill(this.emailChildProcess.pid) - - this.emailChildProcess = null - MockSmtpServer.instance = null - } - - static get Instance () { - return this.instance || (this.instance = new this()) - } -} - -// --------------------------------------------------------------------------- - -export { - MockSmtpServer -} diff --git a/shared/extra-utils/miscs/index.ts b/shared/extra-utils/miscs/index.ts new file mode 100644 index 000000000..ccacd4c79 --- /dev/null +++ b/shared/extra-utils/miscs/index.ts @@ -0,0 +1,3 @@ +export * from './miscs' +export * from './sql' +export * from './stubs' -- cgit v1.2.3