Skip to content

Instantly share code, notes, and snippets.

@EndangeredMassa
Created March 28, 2012 22:10
Show Gist options
  • Save EndangeredMassa/2230984 to your computer and use it in GitHub Desktop.
Save EndangeredMassa/2230984 to your computer and use it in GitHub Desktop.
A command-line script to strip out display:none declarations to include in your test runners
#!/usr/bin/env coffee
CSSOM = require 'cssom'
fs = require 'fs'
if process.argv.length != 4
console.log('Usage: ./hidey inputFile outputFile')
return
fileName = process.argv[2]
outputFileName = process.argv[3]
input = fs.readFileSync(fileName).toString()
parsed = CSSOM.parse(input)
output = ''
for rule in parsed.cssRules
output += "#{rule.selectorText} { display: none; }\r\n" if rule.style['display'] == 'none'
fs.open outputFileName, 'w', '0666', ( e, id ) ->
fs.write id, output, null, 'utf8', ->
fs.close id, ->
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment