Permalink
Browse files

Added script to search template for string

  • Loading branch information...
davidmerfield committed Jan 9, 2019
1 parent 3489d7c commit e858078c025ba5757b73d7eb07ddd384b24e1030
Showing with 34 additions and 0 deletions.
  1. +34 −0 scripts/template/search.js
@@ -0,0 +1,34 @@
var eachView = require("../each/view");
var query = process.argv[2];
var total = 0;
var matches = 0;

eachView(
function(user, blog, template, view, next) {

if (!view || !view.content) return next();

total++;

if (view.content.indexOf(query) === -1) return next();

matches++;

console.log(template.name, view.name, 'matches:');

view.content.split('\n').forEach(function(line, i){

if (line.indexOf(query) === -1) return;

console.log('Line ' + i, line);
});

next();
},
function(err) {
if (err) throw err;
console.log("Searched all " + total + " views.");
console.log("Found " + matches + " views containing \"" + query + "\"");
process.exit();
}
);

0 comments on commit e858078

Please sign in to comment.