<commit_before>require('dotenv').config();
const email = require('emailjs');
const config = {
    user: process.env.EMAIL_USER,
    password: <PASSWORD>,
    host: process.env.EMAIL_HOST || 'email-smtp.us-east-1.amazonaws.com',
    port: +process.env.EMAIL_PORT || 587,
    tls: process.env.EMAIL_TLS ? process.env.EMAIL_TLS === 'true' : true,
};
let server = null;

module.exports = function (message, callback) {
    if (!server) {
        server = email.server.connect(config);
    }
    if (callback) {
        server.send(message, callback);
    }
    else {
        return new Promise(function (resolve, reject) {
            server.send(message, function (err, message) {
                if (err) {
                    reject(err);
                }
                else {
                    resolve(message);
                }
            });
        });
    }
};<commit_msg>add command-line test of email setup to send-email.js<commit_after>#!/usr/bin/env node

require('dotenv').config();
const email = require('emailjs');
const config = {
    user: process.env.EMAIL_USER,
    password: <PASSWORD>,
    host: process.env.EMAIL_HOST || 'email-smtp.us-east-1.amazonaws.com',
    port: +process.env.EMAIL_PORT || 587,
    tls: process.env.EMAIL_TLS ? process.env.EMAIL_TLS === 'true' : true,
};
let server = null;

if (require.main === module) {
    // Called directly
    sendEmail({
        text: 'Test message from ' + __filename,
        from: process.env.EMAIL_SENDER,
        to: process.env.EMAIL_RECIPIENT,
        subject: 'Test message ' + new Date().toLocaleTimeString(),
    })
        .then(() => console.log('Test email sent'));
}

function sendEmail(message, callback) {
    if (!server) {
        server = email.server.connect(config);
    }
    if (callback) {
        server.send(message, callback);
    }
    else {
        return new Promise(function (resolve, reject) {
            server.send(message, function (err, message) {
                if (err) {
                    reject(err);
                }
                else {
                    resolve(message);
                }
            });
        });
    }
}

module.exports = sendEmail;
{'fraction_non_alphanumeric': 0.14128440366972478, 'fraction_numerical': 0.003669724770642202, 'mean_word_length': 2.0041322314049586, 'pattern_counts': {'":': 0, '<': 5, '<?xml version=': 0, '>': 6, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '4762275', 'n_tokens_mistral': 671, 'n_tokens_neox': 648, 'n_words': 136}