Skip to content

Instantly share code, notes, and snippets.

@pauldambra
Created September 21, 2014 18:13
Show Gist options
  • Save pauldambra/77e198c9786a0223789d to your computer and use it in GitHub Desktop.
Save pauldambra/77e198c9786a0223789d to your computer and use it in GitHub Desktop.
'use strict';
var less=require('less');
var fs = require('fs');
var getTree = function(filePath, callback) {
var parser = new(less.Parser)();
fs.readFile(filePath, function (err, data) {
if (err) callback(err);
parser.parse(data.toString(), function (err, tree) {
callback(err, tree);
});
});
};
var getRGBValueFor = function(variableName, tree) {
var value = tree.variable(variableName).value.eval();
return value.rgb;
};
module.exports.getTree = getTree;
module.exports.getRGBValueFor = getRGBValueFor;
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment