logginator
Advanced tools
Comparing version 1.1.1 to 1.1.2
32
index.js
@@ -0,1 +1,2 @@ | ||
var fs = require('fs'); | ||
var path = require('path'); | ||
@@ -7,9 +8,28 @@ var winston = require('winston'); | ||
function moduleName() { | ||
if (module && module.parent && module.parent.id) { | ||
var moduleFile = path.basename(module.parent.id); | ||
var nameMatch = /(.*)\.js$/.exec(moduleFile); | ||
if (nameMatch && nameMatch[1]) | ||
return nameMatch[1]; | ||
function moduleId() { | ||
if (module && module.parent && module.parent.id) { | ||
var id = module.parent.id; | ||
var moduleFile = path.basename(id); | ||
var nameMatch = /(.*)\.js$/.exec(moduleFile); | ||
if (nameMatch && nameMatch[1]) | ||
return nameMatch[1]; | ||
} | ||
} | ||
return "main"; | ||
function packageDef() { | ||
var ppath = path.dirname(module.parent.filename); | ||
while (ppath) { | ||
var packFile = path.join(ppath, "package.json"); | ||
if (fs.existsSync(packFile)) { | ||
try { | ||
var packageConfig = JSON.parse(fs.readFileSync(packFile)); | ||
return packageConfig.name; | ||
} catch(_) { /* ignore */ } | ||
} | ||
ppath = path.dirname(ppath); | ||
} | ||
} | ||
function filename() { | ||
return path.basename(module.parent.filename); | ||
} | ||
return moduleId() || packageDef() || filename() || "main"; | ||
} | ||
@@ -16,0 +36,0 @@ |
{ | ||
"name": "logginator", | ||
"version": "1.1.1", | ||
"version": "1.1.2", | ||
"description": "Creates an instance of TaggedLogger", | ||
@@ -5,0 +5,0 @@ "main": "index.js", |
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
Filesystem access
Supply chain riskAccesses the file system, and could potentially read sensitive data.
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
2287
46
2