From 070d4eebcca64c319eb6e0fb9bca65716213620b Mon Sep 17 00:00:00 2001 From: Adhiraj Singh Date: Sat, 25 Sep 2021 23:30:59 +0530 Subject: [PATCH] respect printQRInTerminal --- src/Socket/socket.ts | 13 ++++++++----- 1 file changed, 8 insertions(+), 5 deletions(-) diff --git a/src/Socket/socket.ts b/src/Socket/socket.ts index bceaf68..3bb2472 100644 --- a/src/Socket/socket.ts +++ b/src/Socket/socket.ts @@ -25,7 +25,8 @@ export const makeSocket = ({ keepAliveIntervalMs, version, browser, - auth: initialAuthState + auth: initialAuthState, + printQRInTerminal, }: SocketConfig) => { const ws = new WebSocket(waWebSocketUrl, undefined, { origin: DEFAULT_ORIGIN, @@ -400,10 +401,12 @@ export const makeSocket = ({ // QR gen ws.on('CB:iq,type:set,pair-device', async (stanza: BinaryNode) => { const postQR = async() => { - const QR = await import('qrcode-terminal').catch(err => { - logger.error('add `qrcode-terminal` as a dependency to auto-print QR') - }) - QR?.generate(qr, { small: true }) + if(printQRInTerminal) { + const QR = await import('qrcode-terminal').catch(err => { + logger.error('add `qrcode-terminal` as a dependency to auto-print QR') + }) + QR?.generate(qr, { small: true }) + } } const refs = ((stanza.content[0] as BinaryNode).content as BinaryNode[]).map(n => n.content as string)