Skip to content

Instantly share code, notes, and snippets.

@henrahmagix
Created February 7, 2017 14:17
Show Gist options
  • Save henrahmagix/e53bfccd9ff2066a4e14dd3a08df25c1 to your computer and use it in GitHub Desktop.
Save henrahmagix/e53bfccd9ff2066a4e14dd3a08df25c1 to your computer and use it in GitHub Desktop.
Find all selectors in a CSS file. Requires https://github.com/tonyganch/gonzales-pe
var fs = require('fs');
var infile = 'mycssfile.css;'
var input = fs.readFileSync(infile).toString();
var parseTree = require('gonzales-pe').parse(input);
var output = [];
parseTree.traverseByType('selector', node => output.push(node.toString()));
fs.writeFileSync('allselectors.txt', output.join('\n'));
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment