From 64225fd091267baebd91fd6ab09fa9cb7675ae6d Mon Sep 17 00:00:00 2001 From: Matt Simerson Date: Thu, 6 Dec 2018 09:41:23 -0800 Subject: [PATCH] hoist variables above first use fixes #14 --- .gitignore | 1 + Changes.md | 4 ++++ index.js | 7 +++++-- package.json | 2 +- test/index.js | 18 +++++++++--------- 5 files changed, 20 insertions(+), 12 deletions(-) diff --git a/.gitignore b/.gitignore index 5148e52..cc1ea7b 100644 --- a/.gitignore +++ b/.gitignore @@ -29,6 +29,7 @@ build/Release # Dependency directories node_modules jspm_packages +package-lock.json # Optional npm cache directory .npm diff --git a/Changes.md b/Changes.md index 6e12b10..8cba4f5 100644 --- a/Changes.md +++ b/Changes.md @@ -1,4 +1,8 @@ +# 1.0.6 - 2018-12-06 + +- move declarations up to restore `var` variable hoisting behavior + # 1.0.5 - 2018-11-16 - reduce severity of log message when no passing dkim results diff --git a/index.js b/index.js index e2f6ac3..5f1ff6d 100644 --- a/index.js +++ b/index.js @@ -41,6 +41,9 @@ exports.update_sender = function (next, connection, params) { // queue_ok arguments: next, connection, msg // ok 1390590369 qp 634 (F82E2DD5-9238-41DC-BC95-9C3A02716AD2.1) + let sender_od; + let rcpt_domains; + function errNext (err) { connection.logerror(plugin, 'update_sender: ' + err); next(null, null, sender_od, rcpt_domains); @@ -52,10 +55,10 @@ exports.update_sender = function (next, connection, params) { if (!connection.relaying) return next(); const txn = connection.transaction; - const sender_od = plugin.get_sender_domain_by_txn(txn); + sender_od = plugin.get_sender_domain_by_txn(txn); if (!sender_od) return errNext('no sender domain'); - const rcpt_domains = plugin.get_recipient_domains_by_txn(txn); + rcpt_domains = plugin.get_recipient_domains_by_txn(txn); if (rcpt_domains.length === 0) { return errNext('no rcpt ODs for ' + sender_od); } diff --git a/package.json b/package.json index 8a3f16a..7d155de 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "haraka-plugin-known-senders", - "version": "1.0.5", + "version": "1.0.6", "description": "Increase the reputation of recognized sender domains.", "main": "index.js", "scripts": { diff --git a/test/index.js b/test/index.js index 93bcf41..a88c418 100644 --- a/test/index.js +++ b/test/index.js @@ -85,7 +85,7 @@ describe('is_authenticated', function () { }, connection); }); -}); +}) describe('check_recipient', function () { let connection; @@ -110,7 +110,7 @@ describe('check_recipient', function () { connection, new Address('')); }); -}); +}) describe('update_sender', function () { @@ -165,13 +165,13 @@ describe('update_sender', function () { }, connection); }); -}); +}) describe('get_rcpt_ods', function () { it('always returns an array', function (done) { done(); }); -}); +}) describe('get_sender_domain_by_txn', function () { @@ -203,7 +203,7 @@ describe('get_sender_domain_by_txn', function () { assert.equal(plugin.get_sender_domain_by_txn(this.connection.transaction), 'bbc.co.uk'); done(); }); -}); +}) describe('get_recipient_domains_by_txn', function () { @@ -244,7 +244,7 @@ describe('get_recipient_domains_by_txn', function () { assert.deepEqual(rcpt_doms, ['example.com'], rcpt_doms); done(); }); -}); +}) describe('is_dkim_authenticated', function () { @@ -259,7 +259,7 @@ describe('is_dkim_authenticated', function () { this.connection.transaction.results = new fixtures.result_store(this.connection); done(); - }); + }) after(function (done) { this.plugin.shutdown(); @@ -280,5 +280,5 @@ describe('is_dkim_authenticated', function () { done(); }, connection); - }); -}); + }) +})