Comparing version 2.0.1 to 3.0.0
'use strict' | ||
var path = require('path') | ||
var fs = require('fs') | ||
const path = require('path') | ||
const fs = require('fs') | ||
@@ -40,5 +40,5 @@ /** | ||
if (fs.existsSync(startAt) && fs.statSync(startAt).isDirectory()) { | ||
var dirs = path.resolve(startAt).split(path.sep) | ||
for (var i = 0; i < dirs.length; i++) { | ||
var basedir = i < dirs.length - 1 | ||
const dirs = path.resolve(startAt).split(path.sep) | ||
for (let i = 0; i < dirs.length; i++) { | ||
const basedir = i < dirs.length - 1 | ||
? dirs.slice(0, dirs.length - i).join(path.sep) | ||
@@ -45,0 +45,0 @@ : path.sep |
{ | ||
"name": "walk-back", | ||
"author": "Lloyd Brookes <75pound@gmail.com>", | ||
"version": "2.0.1", | ||
"version": "3.0.0", | ||
"description": "Walk up the directory tree until the specified path is found.", | ||
@@ -24,9 +24,9 @@ "repository": "https://github.com/75lb/walk-back.git", | ||
"scripts": { | ||
"test": "tape test/*.js", | ||
"test": "test-runner test/*.js", | ||
"docs": "jsdoc2md -t jsdoc2md/README.hbs lib/*.js > README.md; echo" | ||
}, | ||
"devDependencies": { | ||
"jsdoc-to-markdown": "^1.3.6", | ||
"tape": "^4.5.1" | ||
"jsdoc-to-markdown": "^3.0.0", | ||
"test-runner": "^0.3.0" | ||
} | ||
} |
@@ -48,2 +48,2 @@ [![view on npm](http://img.shields.io/npm/v/walk-back.svg)](https://www.npmjs.org/package/walk-back) | ||
© 2015-16 Lloyd Brookes \<75pound@gmail.com\>. Documented by [jsdoc-to-markdown](https://github.com/jsdoc2md/jsdoc-to-markdown). | ||
© 2015-17 Lloyd Brookes \<75pound@gmail.com\>. Documented by [jsdoc-to-markdown](https://github.com/jsdoc2md/jsdoc-to-markdown). |
@@ -1,44 +0,36 @@ | ||
var test = require('tape') | ||
var walkBack = require('../') | ||
const TestRunner = require('test-runner') | ||
const walkBack = require('../') | ||
const a = require('assert') | ||
test('basic', function (t) { | ||
t.plan(1) | ||
const runner = new TestRunner() | ||
var filename = walkBack(__dirname + '/fixture/subdir', 'file.txt') | ||
t.ok(filename.search('walk-back/test/fixture/subdir/file.txt') > 0) | ||
runner.test('basic', function (t) { | ||
const filename = walkBack(__dirname + '/fixture/subdir', 'file.txt') | ||
a.ok(filename.search('walk-back/test/fixture/subdir/file.txt') > 0) | ||
}) | ||
test('basic2', function (t) { | ||
t.plan(1) | ||
var filename = walkBack(__dirname + '/fixture', 'file.txt') | ||
t.ok(filename.search('walk-back/test/fixture/file.txt') > 0) | ||
runner.test('basic2', function (t) { | ||
const filename = walkBack(__dirname + '/fixture', 'file.txt') | ||
a.ok(filename.search('walk-back/test/fixture/file.txt') > 0) | ||
}) | ||
test('not found', function (t) { | ||
t.plan(1) | ||
var filename = walkBack(__dirname + '/fixture', 'adskjfhladfn') | ||
t.strictEqual(filename, null) | ||
runner.test('not found', function (t) { | ||
const filename = walkBack(__dirname + '/fixture', 'adskjfhladfn') | ||
a.strictEqual(filename, null) | ||
}) | ||
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) | ||
runner.test('relative path', function (t) { | ||
const filename = walkBack('.', 'test/fixture/subdir/file.txt') | ||
a.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) | ||
runner.test('relative path 2', function (t) { | ||
const filename = walkBack('./test/fixture/subdir', 'file.txt') | ||
a.ok(filename && filename.search('walk-back/test/fixture/subdir/file.txt') > 0) | ||
}) | ||
test('startPath doesn\'t exist', function (t) { | ||
t.throws(function () { | ||
walkBack('slfnavnkln', 'file.txt') | ||
runner.test('startPath doesn\'t exist', function (t) { | ||
a.throws(function () { | ||
walkBack('slfnavnkln', 'file.txt') | ||
}) | ||
t.end() | ||
}) |
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
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
7010
81