Comparing version 0.0.6 to 0.0.7
@@ -65,33 +65,39 @@ var fs = require('fs'); | ||
var charset = opt.charset || 'utf-8'; | ||
var debug = process.env.DEBUG || opt.debug; | ||
var doCompress = 'compress' in opt ? opt.compress : true; | ||
var doCache = opt.fresh ? false : doCache; | ||
var _doCache = opt.fresh ? false : doCache; | ||
var str = doCache ? (cache[filepath] || global_cache[filepath]) : ''; | ||
var str = _doCache ? (cache[filepath] || global_cache[filepath]) : ''; | ||
if (str && doCache) return str; | ||
if (str && _doCache) return str; | ||
str = fs.readFileSync(filepath, charset); | ||
try { | ||
str = fs.readFileSync(filepath, charset); | ||
} catch (e) { | ||
console.error('[istatic] Reading..', filepath, e); | ||
} | ||
switch (filetype) { | ||
case 'js': | ||
str = _uglify('js', str, opt.js, doCompress); | ||
break; | ||
case 'styl': | ||
filetype = 'css'; | ||
stylus.render(str, function(err, str) { | ||
if (!err) cache[filepath] = _uglify('css', str, opt.css, doCompress); | ||
if (err) console.error('[istatic] Compiling', filepath, err); | ||
else cache[filepath] = _uglify('css', str, opt.css, doCompress); | ||
}); | ||
case 'less': | ||
filetype = 'css'; | ||
less.render(str, function(err, str) { | ||
if (!err) cache[filepath] = _uglify('css', str, opt.css, doCompress); | ||
if (err) console.error('[istatic] Compiling', filepath, err); | ||
else cache[filepath] = _uglify('css', str, opt.css, doCompress); | ||
}); | ||
// better simple than none | ||
// once the render is done, we can safely return good css | ||
break; | ||
case 'css': | ||
str = _uglify('css', str, opt.css, doCompress); | ||
//case 'js': | ||
//case 'css': | ||
default: | ||
// return the original str | ||
if (filetype == 'css' || filetype == 'js') | ||
str = _uglify(filetype, str, opt[filetype], doCompress); | ||
} | ||
if (opt.showPath) str = '\n/* == istatic: ' + filepath + ' == */\n' + str; | ||
if (doCache) cache[filepath] = global_cache[filepath] = str; | ||
if (debug) str = '\n/* == istatic: ' + filepath + ' == */\n' + str; | ||
if (_doCache) cache[filepath] = global_cache[filepath] = str; | ||
return str; | ||
@@ -98,0 +104,0 @@ }; |
{ | ||
"name": "istatic", | ||
"version": "0.0.6", | ||
"version": "0.0.7", | ||
"homepage": "http://github.com/ktmud/express-istatic", | ||
@@ -5,0 +5,0 @@ "description": "Add compressed inline css and scripts to your html, but write them as seperated files.", |
Environment variable access
Supply chain riskPackage accesses environment variables, which may be a sign of credential stuffing or data theft.
Found 1 instance in 1 package
11418
143
3