Comparing version 0.3.5 to 0.3.6
@@ -11,2 +11,3 @@ | ||
path = require('path'), | ||
chalk = require('chalk'), | ||
CrushIt; | ||
@@ -25,3 +26,2 @@ | ||
this.options = {}; | ||
this.max = false; | ||
}; | ||
@@ -51,3 +51,3 @@ | ||
if (!website || typeof callback !== 'function') { | ||
self.echoMsg('Error: unknown arguments, please check documentation'); | ||
self.echoMsg('unknown arguments, please check documentation', 'error'); | ||
return false; | ||
@@ -71,4 +71,5 @@ } | ||
self.scripts = scripts; | ||
if (self.externalScripts) { | ||
self.echoMsg('Preparing to download external scripts....'); | ||
self.echoMsg('Preparing to download external scripts....', 'info'); | ||
} | ||
@@ -114,3 +115,3 @@ self.loadScripts(); | ||
num_external++; | ||
self.echoMsg('found external script(' + num_external + ') - ' + path.basename(src)); | ||
self.echoMsg('found external script(' + num_external + ') ' + chalk.yellow(path.basename(src)), 'info'); | ||
} | ||
@@ -124,3 +125,3 @@ else { | ||
num_inline++; | ||
self.echoMsg('found inline script(' + num_inline + ')'); | ||
self.echoMsg('found inline script(' + num_inline + ')', 'info'); | ||
} | ||
@@ -149,3 +150,3 @@ }); | ||
self.echoMsg('downloading ' + parsedUrl); | ||
self.echoMsg('downloading ' + chalk.yellow(parsedUrl), 'info'); | ||
@@ -161,6 +162,6 @@ http.get(parsedUrl, function (res) { | ||
if (flag) { | ||
self.echoMsg('Success: Loaded url without pathname: ' + parsedUrl); | ||
self.echoMsg('loaded url without pathname: ' + chalk.yellow(parsedUrl), 'success'); | ||
} | ||
else { | ||
self.echoMsg('download complete: ' + path.basename(parsedUrl)); | ||
self.echoMsg('download complete: ' + chalk.yellow(path.basename(parsedUrl)), 'success'); | ||
} | ||
@@ -174,7 +175,7 @@ | ||
if (!flag) { | ||
self.echoMsg('failed to load ' + parsedUrl + '\n Try again using base url without pathname'); | ||
self.echoMsg('failed to load ' + chalk.yellow(parsedUrl) + '\n Try again using base url without pathname', 'error'); | ||
self.loadScript(urlStr, website, fn, true); | ||
} | ||
else { | ||
self.echoMsg('Error: failed to load ' + parsedUrl); | ||
self.echoMsg('failed to load ' + chalk.yellow(parsedUrl), 'error'); | ||
fn(error, ''); | ||
@@ -213,3 +214,3 @@ } | ||
// parse the javascript | ||
ast = uglify.parse(script.data, {strict: self.strict}); | ||
ast = uglify.parse(script.data, {strict: self.options.strict}); | ||
@@ -273,7 +274,17 @@ // write it to our stream | ||
*/ | ||
echoMsg: function(msg) { | ||
echoMsg: function(msg, tyyp) { | ||
"use strict"; | ||
console.log(' > %s', msg); | ||
}, | ||
var arrow = 'crushit > '; | ||
if (tyyp === 'error') { | ||
arrow = chalk.red(arrow); | ||
} | ||
else if (tyyp === 'success') { | ||
arrow = chalk.green(arrow); | ||
} | ||
console.log(arrow + msg); | ||
} | ||
}; | ||
@@ -280,0 +291,0 @@ |
@@ -6,3 +6,4 @@ | ||
var url = require('url'), urlBase, urlPath, parseUrl, resolveUrl, echoMsg; | ||
var url = require('url'), | ||
path = require('path'); | ||
@@ -17,3 +18,3 @@ | ||
*/ | ||
urlBase = function (urlStr) { | ||
function urlBase(urlStr) { | ||
"use strict"; | ||
@@ -26,3 +27,3 @@ | ||
return base; | ||
}; | ||
} | ||
@@ -39,16 +40,24 @@ | ||
*/ | ||
urlPath = function (urlStr) { | ||
function urlPath(urlStr) { | ||
"use strict"; | ||
var urlObject = url.parse(urlStr), pathname; | ||
var urlObject = url.parse(urlStr), pathname, ext; | ||
pathname = urlObject.pathname; | ||
ext = path.extname(pathname); | ||
if (pathname.indexOf('.htm') > 0 || pathname.indexOf('.html') > 0 || pathname.indexOf('.shtml') > 0 || pathname.indexOf('.jsp') > 0 || pathname.indexOf('.asp') > 0 || pathname.indexOf('.cgi') > 0 || pathname.indexOf('.php') > 0 || pathname.indexOf('.pl') > 0 ) | ||
{ | ||
pathname = pathname.substring(0, pathname.lastIndexOf('/')); | ||
switch (ext) { | ||
case '.htm': | ||
case '.html': | ||
case '.shtml': | ||
case '.asp': | ||
case '.cgi': | ||
case '.pl': | ||
case '.php': | ||
pathname = pathname.substring(0, pathname.lastIndexOf('/')); | ||
break; | ||
} | ||
return parseUrl(pathname); | ||
}; | ||
} | ||
@@ -65,3 +74,3 @@ | ||
*/ | ||
parseUrl = function (urlStr) { | ||
function parseUrl(urlStr) { | ||
"use strict"; | ||
@@ -80,3 +89,3 @@ | ||
return urlStr; | ||
}; | ||
} | ||
@@ -95,3 +104,3 @@ | ||
*/ | ||
resolveUrl = function (urlStr, website, flag) { | ||
function resolveUrl(urlStr, website, flag) { | ||
"use strict"; | ||
@@ -121,3 +130,3 @@ | ||
return resolvedUrl; | ||
}; | ||
} | ||
@@ -124,0 +133,0 @@ |
{ | ||
"name": "crushit", | ||
"version": "0.3.5", | ||
"version": "0.3.6", | ||
"description": "CrushIt is a commandline tool for crawling web pages and compiling scripts", | ||
@@ -31,3 +31,4 @@ "homepage": "http://qawemlilo.github.io/crushit/", | ||
"uglify-js": "~2.4.12", | ||
"commander": "~2.1.0" | ||
"commander": "~2.1.0", | ||
"chalk": "~0.4.0" | ||
}, | ||
@@ -34,0 +35,0 @@ "preferGlobal": true, |
@@ -0,0 +0,0 @@ # CrushIt |
@@ -0,0 +0,0 @@ var q = null; |
@@ -7,3 +7,2 @@ | ||
http = require('http'), | ||
url = require('url'), | ||
localhost = 'http://localhost:8070', | ||
@@ -29,3 +28,3 @@ instance; | ||
if (route == 'script.js') { | ||
if (route === 'script.js') { | ||
res.end(script); | ||
@@ -32,0 +31,0 @@ } |
@@ -0,0 +0,0 @@ |
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
875
43842
4
12
+ Addedchalk@~0.4.0
+ Addedansi-styles@1.0.0(transitive)
+ Addedchalk@0.4.0(transitive)
+ Addedhas-color@0.1.7(transitive)
+ Addedstrip-ansi@0.1.1(transitive)