Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

walk-back

Package Overview
Dependencies
Maintainers
1
Versions
13
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

walk-back - npm Package Compare versions

Comparing version 1.0.1 to 1.1.0

7

lib/walk-back.js

@@ -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

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc