Skip to content

Instantly share code, notes, and snippets.

@jeremy2
Created January 30, 2012 16:20
Show Gist options
  • Select an option

  • Save jeremy2/1705248 to your computer and use it in GitHub Desktop.

Select an option

Save jeremy2/1705248 to your computer and use it in GitHub Desktop.

Revisions

  1. jeremy2 created this gist Jan 30, 2012.
    12 changes: 12 additions & 0 deletions colorsExtractor
    Original file line number Diff line number Diff line change
    @@ -0,0 +1,12 @@
    function readColors() {
    var file = 'public/stylesheets/less/_colors.less';
    var data = fs.readFileSync(file, 'utf-8');
    data = data.replace(/(.*): *(.*);/gm, '"$1":"$2",');
    data = data.replace(/\/\/.*$/gm, '');
    var i = data.lastIndexOf(',');
    data = data.substring(0,i);
    data = '{'+ data +'}';
    data = JSON.parse(data);
    console.log('json: '+ JSON.stringify(data));
    return data;
    }