summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJoe Robinson <joe@lc8n.com>2015-12-05 18:44:59 +0000
committerJoe Robinson <joe@lc8n.com>2015-12-05 18:44:59 +0000
commit48eb01696d0adc16a66dbf560f5c5771f6ea5428 (patch)
tree013cbd268ee238893b1aa7eefa0dd2114ebfd284
parentff74f82dff02a8e2676aa30fef85adfea02dfc5a (diff)
Take search query as argsHEADmaster
-rw-r--r--search.js17
1 files changed, 14 insertions, 3 deletions
diff --git a/search.js b/search.js
index fda4604..e693bad 100644
--- a/search.js
+++ b/search.js
@@ -12,12 +12,11 @@ var options = {
headers: { "Cookie": cookie }
};
-var query = 'beans'
+var query = process.argv.slice(2,process.argv.length)
function result(error, response, body) {
if (!error && response.statusCode == 200) {
var results = JSON.parse(body);
- //console.log(results);
search(query, results);
}
}
@@ -25,10 +24,22 @@ function result(error, response, body) {
function search(query, json) {
json.forEach(function(item) {
- if (item.filename.search(query) > 0) {
+ if (matches(query, item.filename)) {
console.log(item.filename);
}
});
}
+function matches(query, filename) {
+
+ var matches = true;
+ query.forEach(function(word) {
+ if(filename.search(word) == -1) {
+ matches = false;
+ return;
+ }
+ });
+ return matches;
+}
+
request(options, result);