-
-
Notifications
You must be signed in to change notification settings - Fork 203
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
Sanitize whitespace from config objects. #43
Sanitize whitespace from config objects. #43
Conversation
This commit adds logic to recursively sanitize the configuration object before it's written out to disk. It trims leading and trailing whitespace from string values in arrays or objects. Fixes kevinschaich#42
c772709
to
901b3e3
Compare
const sanitize = (chunk) => { | ||
return _.reduce(chunk, (result, v, k) => { | ||
if (_.isObject(v) || _.isArray(v)) { | ||
result[k] = sanitize(v); |
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.
This is where we recursively call this function to sanitize nested objects and arrays.
@@ -101,10 +101,27 @@ const getConfigEnv = async options => | |||
options | |||
) | |||
|
|||
const sanitizeConfig = config => { | |||
// recurse configuration objects and arrays to remove whitespace | |||
const sanitize = (chunk) => { |
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.
Throughout, I opted to use lodash convenience methods since you had already included the package. If you'd prefer I use native methods (e.g. Array.isArray
, native .trim()
) let me know and I can swap them out!
Edit looks good to me @blimmer – however we seem to have broken the Travis job (not sure why the exit code is 0 but it didn't finish successfully): |
Hey @kevinschaich it looks like that problem is because the PR's building off of my fork and doesn't have your
I opened #51 to make it actually fail the build. However, I'm not sure what the ideal fix would be for builds on forks. |
On failure, catch rejected promises and exit with a non-zero exit code to break the build. Relates to kevinschaich#43
Hey @blimmer thanks for that subsequent PR – I’ve also added you as a collaborator so please feel free to make your branches here rather than on a fork to avoid the Travis issue! Will try to think of a workaround for that in the coming weeks. I might be able to just create a public “template” account for Mintable on each of the services so my API keys are not out in the open. |
This commit adds logic to recursively sanitize the configuration object before it's written out to disk. It trims leading and trailing whitespace from string values in arrays or objects.
Fixes #42