-
Notifications
You must be signed in to change notification settings - Fork 26
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Goodparts refactor #70
Conversation
I think the way to ensure the last 2 tests pass is to rewrite the compile_template function. The last 2 tests currently is breaking because the This didn't used to be a problem because before we wouldn't trip into the if statement and we wouldn't evaluate it. But as we are now evaluating this variable (which will sometimes break things), we need to rethink the function |
Prior to refactoring to comply with goodparts, there were some vars in odd places, and goodparts wants them always at the top of whatever scope they're in. You're right, and also moving them may have caused some of the evaluation order breakage. |
On master changing the function compile_template(template_name, type) {
var filepathWithoutExt = process.env.TEMPLATE_DIRECTORY + '/' + template_name;
var filepath = path.resolve(filepathWithoutExt + '.' + type);
var template = !COMPILED_TEMPLATES[template_name+'.'+type]
? fs.readFileSync(filepath, 'utf8')
: '';
var compiled = Handlebars.compile(template);
// check if the template has already been opened
if(!COMPILED_TEMPLATES[template_name+'.'+type]) {
COMPILED_TEMPLATES[template_name+'.'+type] = compiled;
}
return COMPILED_TEMPLATES[template_name+'.'+type];
} But it's a little messy |
Codecov Report@@ Coverage Diff @@
## master #70 +/- ##
=====================================
Coverage 100% 100%
=====================================
Files 1 1
Lines 29 31 +2
=====================================
+ Hits 29 31 +2
Continue to review full report at Codecov.
|
I had to disable a couple of eslint rules, namely no-console before the error check of We could probably get rid of the console exception by throwing a |
I think logging the ses error is fine and using I've rewritten the @newswim let me know what you think |
Looks good! It's also a bit more readable. |
@newswim Do you think we should also remove the |
Good call! I'll remove it |
Looks ready to me. @nelsonic Could you have a quick look and merge if your happy. |
You guys 😍 Thank you for all the work that's gone into this! |
var AWS = require('aws-sdk'); | ||
AWS.config.region = process.env.AWS_REGION; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Do we no longer need to configure the AWS_REGION
before instantiating the SES
client? ❓
var Handlebars = require('handlebars'); // -> compile templates | ||
var COMPILED_TEMPLATES = {}; // -> cache compiled templates | ||
|
||
AWS.config.region = process.env.AWS_REGION; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
can AWS_REGION
be configured down here after SES
has been instantiated?
(good ol OOP, hey...?) 😆
throw "Please Set a Template Directory"; | ||
function set_template_directory (dir) { | ||
if (!dir) { | ||
throw new Error('Please Set a Template Directory'); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
thanks for tidying up this error throwing. 👍
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@newswim this looks so much better!! 😍
(thank you so much for making the time to do this refactor. it's textbook!) 🥇
@Shouston3 thanks for remote-pairing / peer-reviewing the refactor. ❤️ ✅ 🚀
Merging. 👍
@newswim the latest version on NPM |
Hello! This new PR is meant to add GoodParts compliance a la Issue #66 and re-initialize the merge from within the upstream repo rather than my own fork.
It has the following TODOs:
sendemail
is not returning anything, so tests 10 and 11 never end (see failure in action).