Skip to content
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

feat(parser): adding custom parser support #429

Merged
merged 3 commits into from
Sep 21, 2020
Merged

feat(parser): adding custom parser support #429

merged 3 commits into from
Sep 21, 2020

Conversation

dbanksdesign
Copy link
Member

Issue #, if available: #85

Description of changes: Adding custom parser support. This allows you to write token files in any language you like as long as you can parse the file. For example you can write your tokens in YAML and use the yaml.parse. This adds .registerParser as well as documentation, examples, and tests. A custom parser has a file pattern regex to match certain types of files, and a parse function that takes the file contents as a string and returns a plain Javascript object.

By submitting this pull request, I confirm that my contribution is made under the terms of the Apache 2.0 license.

Copy link
Collaborator

@chazzmoney chazzmoney left a comment

Choose a reason for hiding this comment

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

Im in awe. I have no changes to recommend. This is solid stuff.

Thanks for putting this together - I'm sure people will appreciate it in 3.0

@@ -171,7 +171,7 @@ describe('extend', () => {
var StyleDictionaryExtended = StyleDictionary.extend(__dirname + '/__configs/test.json5');
expect(StyleDictionaryExtended).toHaveProperty('platforms.web');
});

Copy link
Collaborator

Choose a reason for hiding this comment

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

👀

@@ -13,6 +13,7 @@

var combineJSON = require('../../lib/utils/combineJSON');
var path = require('path');
const yaml = require('yaml');
Copy link
Collaborator

Choose a reason for hiding this comment

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

For code consistency, should we leave this var for now and then move them all to const when we do the ES6 changeover?

@@ -39,13 +39,15 @@ var StyleDictionary = {
format: require('./lib/common/formats'),
action: require('./lib/common/actions'),
filter: {}, // we need to initialise the object, since we don't have built-in filters
parsers: [], // ditto ^
Copy link
Collaborator

Choose a reason for hiding this comment

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

😂

lib/extend.js Outdated
@@ -103,7 +103,7 @@ function extend(opts) {
if (!_.isArray(options.include))
throw new Error('include must be an array');

to_ret.properties = combineJSON(options.include, true);
to_ret.properties = combineJSON(options.include, true, null, to_ret.parsers);
Copy link
Collaborator

Choose a reason for hiding this comment

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

this might conflict with one of the PRs in progress... not sure which one but I feel like I remember this...

Copy link
Member Author

Choose a reason for hiding this comment

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

Right you are, #356 we should probably merge that one in first and then I'll go fix this afterwards

@dbanksdesign dbanksdesign changed the base branch from master to 3.0 July 20, 2020 16:57
@chazzmoney
Copy link
Collaborator

LGTM! :shipit:

@chazzmoney chazzmoney merged commit 887a837 into 3.0 Sep 21, 2020
@dbanksdesign dbanksdesign deleted the parser-support branch October 6, 2020 16:40
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.

None yet

2 participants