Skip to content

Instantly share code, notes, and snippets.

@shama
Created October 1, 2013 22:33
Show Gist options
  • Save shama/6786297 to your computer and use it in GitHub Desktop.
Save shama/6786297 to your computer and use it in GitHub Desktop.
Remove a line of code in a bunch of files
#!/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