diff --git a/.env.example b/.env.example index 30d7edf..2151df7 100644 --- a/.env.example +++ b/.env.example @@ -1,6 +1,7 @@ EMAIL_USERNAME="youremail@gmail.com" EMAIL_PASSWORD="secretpassword" +EMAIL_TEST="true" +NOTIFICATION_METHODS="email" SLACK_CHANNEL="SlackChannelName" SLACK_TOKEN="slack-token" STORES="bestbuy,bandh,nvidia" -NOTIFICATION_METHODS="email" diff --git a/src/config.ts b/src/config.ts index 6af3025..4cf8881 100644 --- a/src/config.ts +++ b/src/config.ts @@ -5,7 +5,8 @@ config({path: resolve(__dirname, '../.env')}); const email = { username: process.env.EMAIL_USERNAME, - password: process.env.EMAIL_PASSWORD + password: process.env.EMAIL_PASSWORD, + test: process.env.EMAIL_TEST ?? 'false' }; const notifications = { diff --git a/src/index.ts b/src/index.ts index 9815334..604544b 100644 --- a/src/index.ts +++ b/src/index.ts @@ -5,6 +5,13 @@ import open from 'open'; import sendNotification from './notification'; import {Logger} from './logger'; +/** + * Send test email. + */ +if (Config.email.test === 'true') { + sendNotification('test'); +} + /** * Starts the bot. */ @@ -45,6 +52,7 @@ async function lookup(store: Store) { await page.goto(link.url, {waitUntil: 'networkidle0'}); } catch { Logger.error(`✖ [${store.name}] ${graphicsCard} skipping; timed out`); + await browser.close(); return; }