aboutsummaryrefslogtreecommitdiff
path: root/node_modules/glob-parent/index.js
diff options
context:
space:
mode:
authorFlorian Dold <florian.dold@gmail.com>2018-09-20 02:56:13 +0200
committerFlorian Dold <florian.dold@gmail.com>2018-09-20 02:56:13 +0200
commitbbff7403fbf46f9ad92240ac213df8d30ef31b64 (patch)
treec58400ec5124da1c7d56b01aea83309f80a56c3b /node_modules/glob-parent/index.js
parent003fb34971cf63466184351b4db5f7c67df4f444 (diff)
update packages
Diffstat (limited to 'node_modules/glob-parent/index.js')
-rw-r--r--node_modules/glob-parent/index.js20
1 files changed, 17 insertions, 3 deletions
diff --git a/node_modules/glob-parent/index.js b/node_modules/glob-parent/index.js
index 61615f1ac..3a14a539f 100644
--- a/node_modules/glob-parent/index.js
+++ b/node_modules/glob-parent/index.js
@@ -2,9 +2,23 @@
var path = require('path');
var isglob = require('is-glob');
+var pathDirname = require('path-dirname');
+var isWin32 = require('os').platform() === 'win32';
module.exports = function globParent(str) {
- str += 'a'; // preserves full path in case of trailing path separator
- do {str = path.dirname(str)} while (isglob(str));
- return str;
+ // flip windows path separators
+ if (isWin32 && str.indexOf('/') < 0) str = str.split('\\').join('/');
+
+ // special case for strings ending in enclosure containing path separator
+ if (/[\{\[].*[\/]*.*[\}\]]$/.test(str)) str += '/';
+
+ // preserves full path in case of trailing path separator
+ str += 'a';
+
+ // remove path parts that are globby
+ do {str = pathDirname.posix(str)}
+ while (isglob(str) || /(^|[^\\])([\{\[]|\([^\)]+$)/.test(str));
+
+ // remove escape chars and return result
+ return str.replace(/\\([\*\?\|\[\]\(\)\{\}])/g, '$1');
};