Last active
August 29, 2015 14:17
-
-
Save willread/8fa10bac81160f1f45b8 to your computer and use it in GitHub Desktop.
Convert rem units to pixels
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
var glob = require('glob'); | |
var _ = require('lodash'); | |
var fs = require('fs'); | |
var rem = 18; | |
var path = '/path/stuff/**/*.css'; | |
glob(path, {}, function(err, files) { | |
_.each(files, function(file) { | |
fs.readFile(file, 'utf-8', function(err, data) { | |
var converted = data.replace(/(\d+.?\d*)rem/g, function(match, p1) { | |
return Math.floor(p1 * rem) + 'px'; | |
}); | |
fs.writeFile(file, converted, function(err) { | |
console.log('converted ' + file); | |
}); | |
}); | |
}); | |
}); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment