diff --git a/src/drivers/npm/.editorconfig b/src/drivers/npm/.editorconfig new file mode 100644 index 000000000..92b1c978e --- /dev/null +++ b/src/drivers/npm/.editorconfig @@ -0,0 +1,14 @@ +root = true + +[*] +indent_style = tab +end_of_line = lf +insert_final_newline = true +trim_trailing_whitespace = true + +[*.{js,py}] +charset = utf-8 + +[*.py] +indent_style = space +indent_size = 4 diff --git a/src/drivers/npm/.jshintrc b/src/drivers/npm/.jshintrc new file mode 100644 index 000000000..3152f17fc --- /dev/null +++ b/src/drivers/npm/.jshintrc @@ -0,0 +1,5 @@ +{ + "node" : true, + "browser" : "false", + "predef": [] +} \ No newline at end of file diff --git a/src/drivers/npm/index.js b/src/drivers/npm/index.js index c0dd7f684..35ffd2a35 100644 --- a/src/drivers/npm/index.js +++ b/src/drivers/npm/index.js @@ -1,83 +1,86 @@ +'use strict'; + var request = require('request'); -var fs = require("fs"); -var path =require("path"); +var fs = require('fs'); +var path = require('path'); //TODO -exports.detectFromHTML = function (options) {}; +exports.detectFromHTML = function(options) {}; -exports.detectFromUrl = function (options,cb) { - - var url = options.url; +exports.detectFromUrl = function(options, cb) { - if (options.debug ) { - console.log("Fetching the page"); - }; + var url = options.url; - getHTMLFromUrl(url,function (err,data) { - if (err) { - cb(err,null) - }else{ - runWrappalyer(options,data, function (err,detected,appInfo) { - cb(null,detected,appInfo) - }); - } - }) -} + if (options.debug) { + console.log('Fetching the page'); + } + + getHTMLFromUrl(url, function(err, data) { + if (err || data === null) { + cb(err, null); + } else { + runWrappalyer(options, data, function(err, detected, appInfo) { + cb(null, detected, appInfo); + }); + } + }); +}; -function getHTMLFromUrl (url,cb) { - request(url, function(error, response, body) { - if (!error && response.statusCode == 200) { - var data = { - html: body, - url: url, - headers: response - }; - cb(null,data); - }else{ - cb(error,null) - } - }); +function getHTMLFromUrl(url, cb) { + request(url, function(error, response, body) { + if (!error && response.statusCode == 200) { + var data = { + html: body, + url: url, + headers: response + }; + cb(null, data); + } else { + cb(error, null); + } + }); } function getAppsJson(cb) { - fs.readFile(path.resolve(__dirname, 'apps.json'), 'utf8', function(err, data) { - if (err) throw err; - return cb(null, JSON.parse(data)) - }); + fs.readFile(path.resolve(__dirname, 'apps.json'), 'utf8', function(err, data) { + if (err) throw err; + return cb(null, JSON.parse(data)); + }); } -function runWrappalyer(options,data,cb) { - var debug = options.debug || false; +function runWrappalyer(options, data, cb) { + var debug = options.debug || false; - var wappalyzer = require("./wappalyzer").wappalyzer; - getAppsJson(function(err, apps) { - var w = wappalyzer; - w.driver = { - log: function(args) { - if (debug) { - console.log(args.message); - }; - }, + var wappalyzer = require('./wappalyzer').wappalyzer; + getAppsJson(function(err, apps) { + var w = wappalyzer; + w.driver = { + log: function(args) { + if (debug) { + console.log(args.message); + } + }, - init: function() { - w.categories = apps.categories; - w.apps = apps.apps; - }, - displayApps: function() { - var app,url = Object.keys(w.detected)[0]; - var detectedApps = []; - - for (app in w.detected[url]) { - detectedApps.push(app); + init: function() { + w.categories = apps.categories; + w.apps = apps.apps; + }, + displayApps: function() { + var app, url = Object.keys(w.detected)[0]; + var detectedApps = []; - if (debug) { - console.log(app); - }; - }; - cb(null,detectedApps,w.detected[url]) - } - } - w.init(); - w.analyze(options.hostname,options.url, data) - }); -} \ No newline at end of file + for (app in w.detected[url]) { + detectedApps.push(app); + + if (debug) { + console.log(app); + } + } + cb(null, detectedApps, w.detected[url]); + } + }; + w.init(); + w.detected = []; + w.analyze(options.hostname, options.url, data); + }); +} diff --git a/src/drivers/npm/package.json b/src/drivers/npm/package.json index b00c60e6f..d1131c707 100644 --- a/src/drivers/npm/package.json +++ b/src/drivers/npm/package.json @@ -1,6 +1,6 @@ { - "name": "wrappalyzer", - "version": "2.0.0", + "name": "wappalyzer", + "version": "2.0.2", "description": "NPM Module that uncovers the technologies used on websites", "main": "index.js", "scripts": { diff --git a/src/drivers/npm/test/test.js b/src/drivers/npm/test/test.js index ca708b9cd..ce4426172 100644 --- a/src/drivers/npm/test/test.js +++ b/src/drivers/npm/test/test.js @@ -6,7 +6,7 @@ describe('wappalyzer', function(){ var wappalyzer = require("../index"); - var expect = ['AngularJS','Font Awesome','Google Font API','jQuery','Twitter Bootstrap']; + var expect = ['AngularJS','Font Awesome','Google Font API','Twitter Bootstrap','jQuery']; var options={ url : "http://codelanka.github.io/Presentation-Engines",