feat(bulk-mailer): Style fixes
This commit is contained in:
Родитель
897de10205
Коммит
0569500971
|
@ -26,7 +26,7 @@ commandLineOptions
|
|||
.option('--send', 'Send emails, for real. *** THIS REALLY SENDS ***')
|
||||
.parse(process.argv)
|
||||
|
||||
var BATCH_DELAY = typeof commandLineOptions.delay === "undefined" ? 5 : commandLineOptions.delay
|
||||
var BATCH_DELAY = typeof commandLineOptions.delay === 'undefined' ? 5 : commandLineOptions.delay
|
||||
var BATCH_SIZE = commandLineOptions.batchsize || 10
|
||||
|
||||
var ERRORS_REPORT_FILENAME = path.resolve(commandLineOptions.errors || 'errors.json')
|
||||
|
@ -39,7 +39,7 @@ var requiredOptions = [
|
|||
|
||||
requiredOptions.forEach(checkRequiredOption)
|
||||
|
||||
var mailer;
|
||||
var mailer
|
||||
var mailerFunctionName = templateToMailerFunctionName(commandLineOptions.template)
|
||||
|
||||
var currentBatch = []
|
||||
|
@ -123,7 +123,7 @@ function normalizeRecords(records) {
|
|||
|
||||
// first, try to generate a localized locality
|
||||
if (! location.location && location.citynames && location.countrynames) {
|
||||
var parts = [];
|
||||
var parts = []
|
||||
|
||||
var localizedCityName = location.citynames[language]
|
||||
if (localizedCityName) {
|
||||
|
|
|
@ -6,7 +6,7 @@ var fs = require('fs')
|
|||
var path = require('path')
|
||||
|
||||
module.exports = function (config) {
|
||||
var messageId = 0;
|
||||
var messageId = 0
|
||||
|
||||
if (config.outputDir) {
|
||||
ensureOutputDirExists(config.outputDir)
|
||||
|
@ -16,8 +16,6 @@ module.exports = function (config) {
|
|||
sendMail: function (emailConfig, callback) {
|
||||
if (config.outputDir) {
|
||||
|
||||
var language = emailConfig.headers['Content-Language']
|
||||
|
||||
var outputPath = path.join(config.outputDir, emailConfig.to)
|
||||
|
||||
var textPath = outputPath + '.txt'
|
||||
|
@ -39,20 +37,20 @@ module.exports = function (config) {
|
|||
},
|
||||
|
||||
close: function () {}
|
||||
};
|
||||
};
|
||||
}
|
||||
}
|
||||
|
||||
function ensureOutputDirExists(outputDir) {
|
||||
var dirStats
|
||||
try {
|
||||
dirStats = fs.statSync(outputDir)
|
||||
} catch (e) {
|
||||
fs.mkdirSync(outputDir);
|
||||
return;
|
||||
fs.mkdirSync(outputDir)
|
||||
return
|
||||
}
|
||||
|
||||
if (! dirStats.isDirectory()) {
|
||||
console.error(outputDir + ' is not a directory');
|
||||
console.error(outputDir + ' is not a directory')
|
||||
process.exit(1)
|
||||
}
|
||||
}
|
||||
|
|
|
@ -29,7 +29,7 @@ P.resolve()
|
|||
.then(createBatches)
|
||||
.then(writeBatches)
|
||||
.then(function (batches) {
|
||||
var msg = batches.length + ' batch' + (batches.length === 1 ? '' : 'es') + ' created';
|
||||
var msg = batches.length + ' batch' + (batches.length === 1 ? '' : 'es') + ' created'
|
||||
console.log(msg)
|
||||
process.exit(0)
|
||||
})
|
||||
|
@ -74,7 +74,7 @@ function readRecords() {
|
|||
}
|
||||
|
||||
function createBatches(records) {
|
||||
var batches = [];
|
||||
var batches = []
|
||||
|
||||
while (records.length) {
|
||||
var batch = records.splice(0, BATCH_SIZE)
|
||||
|
@ -101,12 +101,12 @@ function ensureOutputDirExists(outputDir) {
|
|||
try {
|
||||
dirStats = fs.statSync(outputDir)
|
||||
} catch (e) {
|
||||
fs.mkdirSync(outputDir);
|
||||
return;
|
||||
fs.mkdirSync(outputDir)
|
||||
return
|
||||
}
|
||||
|
||||
if (! dirStats.isDirectory()) {
|
||||
console.error(outputDir + ' is not a directory');
|
||||
console.error(outputDir + ' is not a directory')
|
||||
process.exit(1)
|
||||
}
|
||||
}
|
||||
|
|
Загрузка…
Ссылка в новой задаче