confortable
Advanced tools
Comparing version 0.1.1 to 0.1.2
@@ -5,14 +5,17 @@ var fs = require('fs') | ||
module.exports = function (name, cwd) { | ||
var cfg; | ||
module.exports = function (name, start) { | ||
start = start || process.cwd(); | ||
var relative = path.relative(process.env.HOME, start) | ||
, differentDrive = (relative === start) | ||
, isAbove = (relative.slice(0, 2) === '..') | ||
, cfg; | ||
cwd = cwd || process.cwd(); | ||
if (path.relative(process.env.HOME, cwd).slice(0, 2) === '..') { | ||
// cwd is outside home, check cwd only | ||
cfg = path.join(cwd, name); | ||
if (differentDrive || isAbove) { | ||
// start is outside home, check start only | ||
cfg = path.join(start, 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; | ||
// start is somewhere under HOME start, so start there and go up until we hit HOME | ||
var dir = start; | ||
while (path.relative(process.env.HOME, dir).slice(0, 2) !== '..') { | ||
@@ -19,0 +22,0 @@ cfg = path.join(dir, name); |
@@ -5,3 +5,3 @@ { | ||
"description": "Finds the right recursively placed config file", | ||
"version": "0.1.1", | ||
"version": "0.1.2", | ||
"repository": { | ||
@@ -8,0 +8,0 @@ "type": "git", |
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
Deprecated
MaintenanceThe maintainer of the package marked it as deprecated. This could indicate that a single version should not be used, or that the package is no longer maintained and any new vulnerabilities will not be fixed.
Found 1 instance in 1 package
4664
51
0