Skip to content

Instantly share code, notes, and snippets.

@tkharuk
Created June 11, 2018 14:48
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save tkharuk/254d548d4344263b9da29aa468093bba to your computer and use it in GitHub Desktop.
Save tkharuk/254d548d4344263b9da29aa468093bba to your computer and use it in GitHub Desktop.
module.exports = (sheet) => {
const variableRegex = /\$(.+):\s+(.+);?/;
const variables = {};
sheet.split('\n').forEach((line) => {
const variable = variableRegex.exec(line);
if (!variable) return;
const name = variable[1].trim();
const value = variable[2].replace(/!default|!important/g, '').trim();
variables[name] = value;
});
return variables;
};
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment