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 @@ }); |
{ | ||
"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" |
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
4091
62
3
+ Addedempty-dir@^0.2.0
+ Addedempty-dir@0.2.1(transitive)