Skip to content

#349: Use js-yaml to parse json, yaml, and yml config files #634

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

Merged

Conversation

fillerwriter
Copy link
Contributor

Addresses #349

Summary of changes: Refactored buildPatternData to use js-yaml library to parse all the config files. Added a unit test to ensure we're picking up the appropriate files.

@bmuenzenmeyer
Copy link
Member

hello @fillerwriter this is certainly a welcome surprise! thanks for this initial bit of work - I am excited to round out PL Node support with yaml.

Copy link
Member

@bmuenzenmeyer bmuenzenmeyer left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I will review this in earnest, but can already see that this may cause problems in the dev-3.0 branch, where we made a bunch of var to const or let changes already. If you'd be so kind as to alter statements back to var, this will make for an easier merge later.

@fillerwriter
Copy link
Contributor Author

@bmuenzenmeyer No problem. I've swapped out the consts that fall outside the additional work I've done.

Copy link
Member

@bmuenzenmeyer bmuenzenmeyer left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks for making those changes. Will pay dividends down the road.

Individual patterns can also have data associated with them, which we implement within pattern_assembler.js here: https://github.com/pattern-lab/patternlab-node/blob/master/core/lib/pattern_assembler.js#L319-L358

For this to be truly feature complete against #349 and the specification, I'd ask that we support pattern-level yaml too.

@fillerwriter
Copy link
Contributor Author

@bmuenzenmeyer Apologies for letting this sit for a bit. I ended up refactoring the logic for loading the config files into helper functions, and swapped out the implementation across the board. I'd like to tighten up the implementation before merging in. If you have any input, I'm interested in hearing it. :-)

Copy link
Member

@bmuenzenmeyer bmuenzenmeyer left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

this was initially extremely confusing to me because I thought configFileLoader was referring to patternlab-config.json when it actuality it was dealing with data.

I like the direction of further encapsulating this data, somewhat similar to how we have a dedicated markdown_parser now.

would you be willing to change this to, say, perhaps data_loader?

@fillerwriter
Copy link
Contributor Author

Sweet. I like data_loader as a name, and can definitely switch. The other thing I'm wanting to do is adjust the footprint of the methods so that fs can be an optional dependency, and ensuring we have at least minimal testing setup for the new code.

I'm hoping to get to this today/tomorrow.

bmuenzenmeyer added a commit that referenced this pull request Mar 21, 2017
we will error handle json during load after #634 solidifies
part of #637
bmuenzenmeyer added a commit that referenced this pull request Mar 21, 2017
…w helper

we will error handle json during load after #634 solidifies
part of #637
@fillerwriter
Copy link
Contributor Author

@bmuenzenmeyer Ready for review. Thanks for your patience.

@bmuenzenmeyer bmuenzenmeyer self-assigned this Apr 5, 2017
@bmuenzenmeyer bmuenzenmeyer merged commit d941ce8 into pattern-lab:dev Sep 11, 2017
@bmuenzenmeyer
Copy link
Member

bmuenzenmeyer commented Sep 11, 2017

Great work! Sorry this took so long! It will be in the next release

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants