Socket
Socket
Sign inDemoInstall

find-npm-prefix

Package Overview
Dependencies
Maintainers
1
Versions
3
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

find-npm-prefix - npm Package Compare versions

Comparing version 1.0.1 to 1.0.2

48

find-prefix.js

@@ -8,7 +8,5 @@ 'use strict'

const path = require('path')
const Bluebird = require('bluebird')
const readdir = Bluebird.promisify(fs.readdir)
function findPrefix (dir) {
return Bluebird.try(() => {
return new Promise((resolve, reject) => {
dir = path.resolve(dir)

@@ -24,5 +22,7 @@

}
if (walkedUp) return dir
return findPrefix_(dir)
if (walkedUp) {
resolve(dir)
} else {
resolve(findPrefix_(dir))
}
})

@@ -37,21 +37,23 @@ }

// directory
if (parent === dir) return original
if (parent === dir) return Promise.resolve(original)
return readdir(dir).then(files => {
if (files.indexOf('node_modules') !== -1 ||
files.indexOf('package.json') !== -1) {
return dir
}
return findPrefix_(parent, original)
}, er => {
// an error right away is a bad sign.
// unless the prefix was simply a non
// existent directory.
if (er && dir === original && er.code !== 'ENOENT') {
throw er
} else {
return original
}
return new Promise((resolve, reject) => {
fs.readdir(dir, (err, files) => {
if (err) {
// an error right away is a bad sign.
// unless the prefix was simply a non
// existent directory.
if (err && dir === original && err.code !== 'ENOENT') {
reject(err)
} else {
resolve(original)
}
} else if (files.indexOf('node_modules') !== -1 ||
files.indexOf('package.json') !== -1) {
resolve(dir)
} else {
resolve(findPrefix_(parent, original))
}
})
})
}
{
"name": "find-npm-prefix",
"version": "1.0.1",
"version": "1.0.2",
"description": "Find the npm project directory associated with for a given directory",

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

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