const fs = require("fs")
const { exec } = require("child_process");
const serverPath = require("./serverPath.js")
const members = require("/etc/newsletter_members.js")
const blogs = require(serverPath+"/blogs/blogs.js")
let finalBlogIndex = blogs.length-1
const final_blog = blogs[finalBlogIndex]
const lastBlogIndex = require(serverPath+"/node/previousBlog.js")
if (finalBlogIndex > lastBlogIndex || process.argv[2] == "--test") {
final_blog[1] = final_blog[1].replace(/(?:\r\n|\r|\n)/g, '
')
final_blog[1] = final_blog[1].replace(/(?:\t)/g, ' ')
final_blog[1] = final_blog[1].replace(/\(/g,'\\(')
final_blog[1] = final_blog[1].replace(/\)/g,'\\)')
final_blog[1] = final_blog[1].replace(/\&/g,'\\&')
final_blog[1] = final_blog[1].replace(/'/g,"\\'")
let imageAttachments = final_blog[3] ? `${final_blog[3].map(image => `-a ${serverPath}/images/${image}`).join('')}` : '';
console.log(imageAttachments);
//console.log(final_blog[1])
if (process.argv[2] == "--test") {
console.log("test")
let command = `echo "