MCPcopy Create free account
hub / github.com/adobe/react-spectrum / getVars

Function getVars

lib/varsToTypeScript.js:49–63  ·  view source on GitHub ↗
(file)

Source from the content-addressed store, hash-verified

47
48// Parse variables from a file with postcss.
49function getVars(file) {
50 let contents = fs.readFileSync(file, 'utf8');
51 let root = postcss.parse(contents);
52
53 let vars = {};
54 root.walkRules(rule => {
55 rule.walkDecls(decl => {
56 if (customPropertyRegExp.test(decl.prop)) {
57 vars[decl.prop] = decl.value;
58 }
59 });
60 });
61
62 return vars;
63}
64
65let globals = getVars(`${__dirname}/../packages/@adobe/spectrum-css-temp/vars/spectrum-global.css`);
66let theme = getVars(`${__dirname}/../packages/@adobe/spectrum-css-temp/vars/spectrum-light.css`);

Callers 1

Calls 1

parseMethod · 0.45

Tested by

no test coverage detected