-
Notifications
You must be signed in to change notification settings - Fork 561
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
Conversation
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.
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
__tests__/extend.test.js
Outdated
@@ -171,7 +171,7 @@ describe('extend', () => { | |||
var StyleDictionaryExtended = StyleDictionary.extend(__dirname + '/__configs/test.json5'); | |||
expect(StyleDictionaryExtended).toHaveProperty('platforms.web'); | |||
}); | |||
|
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.
👀
__tests__/utils/combineJSON.test.js
Outdated
@@ -13,6 +13,7 @@ | |||
|
|||
var combineJSON = require('../../lib/utils/combineJSON'); | |||
var path = require('path'); | |||
const yaml = require('yaml'); |
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 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 ^ |
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.
😂
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); |
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 might conflict with one of the PRs in progress... not sure which one but I feel like I remember this...
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.
Right you are, #356 we should probably merge that one in first and then I'll go fix this afterwards
7340872
to
f71cd81
Compare
LGTM! |
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.