Comparing version 1.0.1 to 1.1.0
@@ -21,2 +21,5 @@ 'use strict' | ||
* | ||
* > walkBack('.', '.bash_profile') | ||
* '/Users/lloyd/.bash_profile' | ||
* | ||
* > walkBack(process.cwd(), 'non-existent.file') | ||
@@ -29,3 +32,3 @@ * null | ||
* Returns an absolute file path (if found) else `null`. | ||
* | ||
* | ||
* @param {string} - the directory to start in | ||
@@ -37,3 +40,3 @@ * @param {string} - the path we're looking for | ||
function walkBack (startAt, lookingFor) { | ||
var dirs = startAt.split(path.sep) | ||
var dirs = path.resolve(startAt).split(path.sep) | ||
for (var i = 0; i < dirs.length; i++) { | ||
@@ -40,0 +43,0 @@ var basedir = i < dirs.length - 1 |
{ | ||
"name": "walk-back", | ||
"author": "Lloyd Brookes <75pound@gmail.com>", | ||
"version": "1.0.1", | ||
"version": "1.1.0", | ||
"description": "Walk up the directory tree until the specified path is found.", | ||
@@ -26,4 +26,5 @@ "repository": "https://github.com/75lb/walk-back.git", | ||
"devDependencies": { | ||
"jsdoc-to-markdown": "^1.3.3", | ||
"tape": "^4.2.0" | ||
} | ||
} |
@@ -24,2 +24,5 @@ [![view on npm](http://img.shields.io/npm/v/walk-back.svg)](https://www.npmjs.org/package/walk-back) | ||
> walkBack('.', '.bash_profile') | ||
'/Users/lloyd/.bash_profile' | ||
> walkBack(process.cwd(), 'non-existent.file') | ||
@@ -26,0 +29,0 @@ null |
@@ -24,1 +24,15 @@ var test = require('tape') | ||
}) | ||
test('relative path', function (t) { | ||
t.plan(1) | ||
var filename = walkBack('.', 'test/fixture/subdir/file.txt') | ||
t.ok(filename && filename.search('walk-back/test/fixture/subdir/file.txt') > 0) | ||
}) | ||
test('relative path 2', function (t) { | ||
t.plan(1) | ||
var filename = walkBack('./test/fixture/subdir', 'file.txt') | ||
t.ok(filename && filename.search('walk-back/test/fixture/subdir/file.txt') > 0) | ||
}) |
Sorry, the diff of this file is not supported yet
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
6331
74
45
2