Created
October 1, 2013 22:33
-
-
Save shama/6786297 to your computer and use it in GitHub Desktop.
Remove a line of code in a bunch of files
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
#!/usr/bin/env node | |
var falafel = require('falafel'); | |
var globule = require('globule'); | |
var fs = require('fs'); | |
var path = require('path'); | |
// Remove this line | |
var line = "grunt.verbose.writeflags(options, 'Options');"; | |
// From all the files in here | |
var base = path.join(__dirname, '..'); | |
function process(file) { | |
return falafel(String(fs.readFileSync(file)), function(node) { | |
if (node.source() === line) { | |
console.log('Updating ' + file + '.'); | |
node.update(''); | |
} | |
}); | |
} | |
globule.find(['**/tasks/**/*.js', '!**/node_modules/**', '!bin/**'], {cwd: base, filter: 'isFile'}).forEach(function(filepath) { | |
filepath = path.join(base, filepath); | |
console.log('Checking ' + filepath + '...'); | |
fs.writeFileSync(filepath, process(filepath)); | |
}); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment