-
Notifications
You must be signed in to change notification settings - Fork 3
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
Data and File Parsing #6
Conversation
* feature-rewrite: Make option translator function testable Add back undefined checking in merge utility Fix bad fixture key Relocate merge utility and add test WTactualF Bugfix merging function Add new merge function and attempt to use it on options
import { merge } from './utils'; | ||
|
||
const defaults = { | ||
data: { | ||
src: ['src/data/**/*.yaml'], | ||
parseFn: (contents, path) => yaml.safeLoad(contents) |
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.
options
can now take a parseFn
to run over data files. This allows a user to parse with something else, e.g. JSON
or something.
Hmmm, commit history looks a bit funky. The diffs look correct, however. |
return dirname(filepath).split(path.sep).pop(); | ||
} | ||
function removeLeadingNumbers (str) { | ||
return str.replace(/^[0-9|\.\-]+/, ''); |
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.
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.
@erikjung Are you comfortable with a possible breaking change? I think this pattern is better, too, but will it cause unexpected side effects or should we be all "full speed ahead, damn the torpedoes"?!
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've pushed some comments/examples on most of those utility functions.
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.
If we're using the pattern from Fabricator verbatim, then we can leave this as-is and make an issue to improve later.
@lyzadanger Looks good. I think it'd be nice to auto-generate some docs for this. |
@erikjung Yes, I'd like to generate some docs. You wanna take that on at some point? |
@lyzadanger Yeah, I'll make an issue. |
Looks good overall. Had to take a bit longer to get through it, but I generally process things slower. |
OK, I'm gonna merge for now! |
This PR introduces a bunch of generalized utility that will make it easier to parse various kinds of files and specifically handles the parsing of data files. It handles some options changes and a lot of tests.
/cc @erikjung @mrgerardorodriguez