-
Notifications
You must be signed in to change notification settings - Fork 9
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
MOB-76 Update logic for exporting copies for JS #63
base: pv/MOB-80-update-dependency-versions
Are you sure you want to change the base?
MOB-76 Update logic for exporting copies for JS #63
Conversation
f235295
to
f1e3f9f
Compare
src/actions/render.js
Outdated
const { groupByKey } = require("../utils/arrayUtils"); | ||
const { flatten } = require("../utils/arrayUtils"); | ||
const Handlebars = require("handlebars"); | ||
const LodashUpdateWith = require("lodash.updatewith"); |
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.
A nit, shouldn't it be lowercase?
src/actions/render.js
Outdated
@@ -43,6 +44,7 @@ const renderLocalizationView = (view, outputType, language, basePath) => { | |||
return localizationTemplate(outputType) | |||
.map((source) => Handlebars.compile(source)) | |||
.map((template) => template(view)) | |||
.map((renderedTemplate) => postTemplateRenderFormatting(renderedTemplate, outputType)) |
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.
Instead of postTemplateRenderFormatting
can we rename it to something indicating what this function does? something like unflattenJson
or something.
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.
Then it's very specific. In this function, we could be doing different things based on output mode,
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.
we could be doing different things based on output mode
Then probably it's against the "single responsibility" principle :D
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.
Ain't it single resposibility, If the responsibility is "postProcessing", whatever that means, based on outputType? o_O
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.
I agree with @pooyahrtn, let's be explicit about what the function is doing. If we ever need more complicated post-processing steps, we can always change the function name later on.
@@ -15,7 +15,7 @@ const accessiblityKeywords = { | |||
VALUE: "VALUE", | |||
}; | |||
|
|||
const outputType = { | |||
const outputTypes = { |
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.
I'd say the previous name wasn't that bad, and I would rather keep it to make it easier later to read the git changes.
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.
For these lines, outType (in global scope) & outType (in local scope) is confusing. That's why changed it to this.
Also if you see other objects in this file, they're plural.
src/actions/render.js
Outdated
@@ -43,6 +44,7 @@ const renderLocalizationView = (view, outputType, language, basePath) => { | |||
return localizationTemplate(outputType) | |||
.map((source) => Handlebars.compile(source)) | |||
.map((template) => template(view)) | |||
.map((renderedTemplate) => postTemplateRenderFormatting(renderedTemplate, outputType)) |
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.
I agree with @pooyahrtn, let's be explicit about what the function is doing. If we ever need more complicated post-processing steps, we can always change the function name later on.
Update logic for exporting copies for JS
Before copies were exported as 1-on-1 mapping like :
With this change, copies will be exported as JSON object :
JIRA Ticket :
https://picnic.atlassian.net/browse/MOB-76