New Case Study:See how Anthropic automated 95% of dependency reviews with Socket.Learn More
Socket
Sign inDemoInstall
Socket

find-parent-dir

Package Overview
Dependencies
Maintainers
1
Versions
5
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

find-parent-dir - npm Package Compare versions

Comparing version 0.2.0 to 0.2.1

12

index.js

@@ -9,2 +9,10 @@ 'use strict';

function splitPath(path) {
var parts = path.split(/(\/|\\)/);
if (!parts.length) return parts;
// when path starts with a slash, the first part is empty string
return !parts[0].length ? parts.slice(1) : parts;
}
exports = module.exports = function (currentFullPath, clue, cb) {

@@ -23,3 +31,3 @@

testDir(currentFullPath.split(/(\/|\\)/));
testDir(splitPath(currentFullPath));
}

@@ -37,4 +45,4 @@

}
return testDir(currentFullPath.split(/(\/|\\)/));
return testDir(splitPath(currentFullPath));
}

2

package.json
{
"name": "find-parent-dir",
"version": "0.2.0",
"version": "0.2.1",
"description": "Finds the first parent directory that contains a given file or directory.",

@@ -5,0 +5,0 @@ "main": "find-parent-dir.js",

@@ -6,2 +6,3 @@ 'use strict';

var path = require('path')
var fs = require('fs')
var findParentDir = require('..')

@@ -30,5 +31,16 @@

test('sync finding this dir relative to the test dir', function (t) {
var dir = findParentDir.sync(__dirname, 'find-parent-dir.js');
var dir = findParentDir.sync(__dirname, 'find-parent-dir.js')
t.equals(dir, path.resolve(__dirname))
t.end()
})
test('find no dir when file is in the test dir', function(t) {
var filepath = path.join(__dirname, 'shazam.txt')
fs.writeFileSync(filepath, 'shaq attack')
findParentDir('/etc', 'shazam.txt', function (err, dir) {
fs.unlinkSync(filepath)
t.equals(err, null)
t.equals(dir, null)
t.end()
})
})
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