mini-tools
Advanced tools
Comparing version 0.3.9 to 0.3.10
@@ -72,2 +72,12 @@ "use strict"; | ||
function getTraceroute(){ | ||
try{ | ||
throw new Error('aca estamos'); | ||
}catch(err){ | ||
return err.stack.split('\n')[4]; | ||
} | ||
} | ||
MiniTools.logServe = false; | ||
MiniTools.serveTransforming = function serveTransforming(pathToFile, anyFileOrOptions, extOriginal, extTarget, renderizer, textType){ | ||
@@ -84,2 +94,3 @@ var regExpExtDetect; | ||
} | ||
var traceRoute=renderOptions && renderOptions.trace?'serveContent>'+renderOptions.trace:(MiniTools.logServe?getTraceroute():''); | ||
if(extOriginal){ | ||
@@ -94,10 +105,18 @@ regExpExtDetect =new RegExp('\.'+escapeRegExp(extOriginal)+'$'); | ||
var pathname = 'path' in req ? req.path : url.parse(req.url).pathname; | ||
if(traceRoute){ | ||
console.log('xxxxx-minitools-por-revisar',traceRoute,pathname); | ||
} | ||
if(anyFile && !regExpExtDetect.test(pathname)){ | ||
return next(); | ||
} | ||
var sfn; | ||
Promise.resolve().then(function(){ | ||
var fileName=(pathToFile+(anyFile?'/'+pathname:'')).replace(regExpExtReplace, '.'+extTarget); | ||
sfn=fileName; | ||
return fs.readFile(fileName, {encoding: 'utf8'}); | ||
}).catch(function(err){ | ||
if(anyFile && err.code==='ENOENT'){ | ||
if(traceRoute){ | ||
console.log('xxxxx-minitools: no encontre el archivo',traceRoute,pathname); | ||
} | ||
throw new Error('next'); | ||
@@ -113,2 +132,5 @@ } | ||
}).then(function(htmlText){ | ||
if(traceRoute){ | ||
console.log('XXXXXXXX!!!!-xxxxx-minitools: ENVIANDO el archivo',traceRoute,pathname); | ||
} | ||
MiniTools.serveText(htmlText,textType)(req,res); | ||
@@ -115,0 +137,0 @@ }).catch(MiniTools.serveErr(req,res,next)); |
{ | ||
"name": "mini-tools", | ||
"description": "mini tools for express and others", | ||
"version": "0.3.9", | ||
"version": "0.3.10", | ||
"author": "Codenautas <codenautas@googlegroups.com>", | ||
@@ -6,0 +6,0 @@ "license": "MIT", |
15407
192