Comparing version 0.8.0 to 0.8.1
@@ -1,4 +0,5 @@ | ||
TODO | ||
0.8.1 / 2012-07-03 | ||
================== | ||
* move config finder to own module | ||
* moved config finder to own the `confortable` module | ||
* General code linting and readability improvements | ||
@@ -5,0 +6,0 @@ |
var c = require('colors') | ||
, $ = require('autonomy') | ||
, set = require('subset') | ||
, fs = require('fs') | ||
, path = require('path') | ||
, semver = require('semver') | ||
, version = require('./package').version | ||
, dotfile = require('./.logule') | ||
, defaults = require('./.logule') | ||
, custom = require('confortable')('.logule') | ||
, slice = Array.prototype.slice | ||
, concat = Array.prototype.concat | ||
, config = 'Default config'; | ||
, concat = Array.prototype.concat; | ||
@@ -18,37 +16,3 @@ // Pads a str to a str of length len | ||
// config searching and parsing | ||
var findConfig = function (name) { | ||
var cwd = process.cwd() | ||
, exists = fs.existsSync || path.existsSync | ||
, cfg; | ||
if (path.relative(process.env.HOME, cwd).slice(0, 2) === '..') { | ||
// cwd is outside home, check cwd only | ||
cfg = path.join(cwd, name); | ||
return exists(cfg) ? cfg : null; | ||
} | ||
else { | ||
// cwd is somewhere under HOME start in cwd and go up until we hit HOME | ||
var dir = cwd; | ||
while (path.relative(process.env.HOME, dir).slice(0, 2) !== '..') { | ||
cfg = path.join(dir, name); | ||
if (exists(cfg)) { | ||
return cfg; | ||
} | ||
dir = path.join(dir, '..'); | ||
} | ||
return null; | ||
} | ||
}; | ||
var getConfig = function (name) { | ||
var file = findConfig(name); | ||
if (file === null) { | ||
return {}; | ||
} | ||
config = file; // store path for error msgs | ||
return require(file); | ||
}; | ||
// applyConfig obtains these | ||
// obtained by self-executing config fn | ||
var levels | ||
@@ -61,10 +25,10 @@ , delimMap | ||
(function applyConfig() { | ||
var obj = getConfig('.logule'); | ||
(function () { // get config and precompute everything needed | ||
var rawCfg = (custom) ? require(custom) : {}; | ||
// extend levels on inner levels => no method removals => DI works | ||
var levObj = $.extend(dotfile.levels, obj.levels || {}); | ||
var levObj = $.extend(defaults.levels, rawCfg.levels || {}); | ||
// remaining cfg elements can be read from after a merge | ||
var cfg = $.extend(dotfile, obj); | ||
var cfg = $.extend(defaults, rawCfg); | ||
@@ -76,3 +40,3 @@ // cache color calls in delimMap/levelMap for _log | ||
if (!(fn instanceof Function)) { | ||
console.error("invalid color function for level '" + lvl + "' found in " + config); | ||
console.error("invalid color function for level '" + lvl + "' found in " + custom); | ||
} | ||
@@ -95,6 +59,6 @@ acc[lvl] = fn(cfg.delimiter); | ||
if (!(prefixCol instanceof Function)) { | ||
console.error("invalid color function for prefixCol found in " + config); | ||
console.error("invalid color function for prefixCol found in " + custom); | ||
} | ||
if (!(dateCol instanceof Function)) { | ||
console.error("invalid color function for dateCol found in " + config); | ||
console.error("invalid color function for dateCol found in " + custom); | ||
} | ||
@@ -117,3 +81,3 @@ | ||
if (!(new Date())[f.dateMethod] instanceof Function) { | ||
console.error("Logule found invalid dateMethod in " + config); | ||
console.error("Logule found invalid dateMethod in " + custom); | ||
} | ||
@@ -135,5 +99,5 @@ getDate = function () { | ||
} | ||
d += prep(n.getHours(), 2) | ||
+ ':' + prep(n.getMinutes(), 2) | ||
+ ':' + prep(n.getSeconds(), 2); | ||
d += prep(n.getHours(), 2); | ||
d += ':' + prep(n.getMinutes(), 2); | ||
d += ':' + prep(n.getSeconds(), 2); | ||
if (f.showMs) { | ||
@@ -151,3 +115,3 @@ d += '.' + prep(n.getMilliseconds(), 3); | ||
else { | ||
console.error("Logule found invalid dateType in " + config); | ||
console.error("Logule found invalid dateType in " + custom); | ||
} | ||
@@ -175,4 +139,4 @@ | ||
// instance defaults | ||
var defaults = { | ||
// prototype defaults | ||
var proto = { | ||
version : version | ||
@@ -185,5 +149,5 @@ , removed : [] | ||
// make undeletable instance defaults up the prototype chain | ||
Object.keys(defaults).forEach(function (key) { | ||
Object.keys(proto).forEach(function (key) { | ||
Object.defineProperty(Logger.prototype, key, { | ||
value : defaults[key] | ||
value : proto[key] | ||
, writable : false | ||
@@ -190,0 +154,0 @@ , enumerable : false |
@@ -5,3 +5,3 @@ { | ||
"description": "An advanced console logging library", | ||
"version": "0.8.0", | ||
"version": "0.8.1", | ||
"repository": { | ||
@@ -22,2 +22,3 @@ "type": "git", | ||
"subset": "~0.1.0", | ||
"confortable": "~0.1.0", | ||
"semver": "~1.0.13" | ||
@@ -24,0 +25,0 @@ }, |
Dynamic require
Supply chain riskDynamic require can indicate the package is performing dangerous or unsafe dynamic code execution.
Found 1 instance in 1 package
Dynamic require
Supply chain riskDynamic require can indicate the package is performing dangerous or unsafe dynamic code execution.
Found 1 instance in 1 package
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
2
89372
5
538
+ Addedconfortable@~0.1.0
+ Addedconfortable@0.1.5(transitive)