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

base-cwd

Package Overview
Dependencies
Maintainers
1
Versions
15
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

base-cwd - npm Package Compare versions

Comparing version 0.3.1 to 0.3.2

34

index.js

@@ -11,9 +11,17 @@ /*!

var path = require('path');
var empty = require('empty-dir');
var isValid = require('is-valid-app');
var find = require('find-pkg');
var cached;
module.exports = function(types) {
module.exports = function(types, options) {
if (typeof types !== 'string' && !Array.isArray(types)) {
options = types;
types = undefined;
}
options = options || {};
return function plugin(app) {
if (!isValid(app, 'base-cwd', types)) return;
var cached;

@@ -35,6 +43,22 @@ Object.defineProperty(this, 'cwd', {

}
var pkgPath = find.sync(process.cwd());
var cwd = process.cwd();
if (options.findup === false) {
cached = cwd;
return cwd;
}
var isEmpty = empty.sync(cwd, function(fp) {
return !/\.DS_Store/.test(fp);
});
if (isEmpty) {
cached = cwd;
return cwd;
}
var pkgPath = find.sync(cwd);
if (pkgPath) {
var dir = path.dirname(pkgPath);
if (dir !== process.cwd()) {
if (dir !== cwd) {
cached = dir;

@@ -45,3 +69,3 @@ app.emit('cwd', dir);

}
return process.cwd();
return cwd;
}

@@ -48,0 +72,0 @@ });

3

package.json
{
"name": "base-cwd",
"description": "Base plugin that adds a getter/setter for the current working directory.",
"version": "0.3.1",
"version": "0.3.2",
"homepage": "https://github.com/node-base/base-cwd",

@@ -25,2 +25,3 @@ "author": "Jon Schlinkert (https://github.com/jonschlinkert)",

"dependencies": {
"empty-dir": "^0.2.0",
"find-pkg": "^0.1.2",

@@ -27,0 +28,0 @@ "is-valid-app": "^0.2.0"

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