From 0eb2cd5f7d9094c431a0c05d7da097bf4c7bf4cd Mon Sep 17 00:00:00 2001 From: Evilebot Tnawi Date: Fri, 23 Feb 2018 22:30:02 +0300 Subject: [PATCH] fix(src/): don't escape non-glob patterns (#230) --- src/preProcessPattern.js | 10 ++++++---- src/processPattern.js | 4 ++-- 2 files changed, 8 insertions(+), 6 deletions(-) diff --git a/src/preProcessPattern.js b/src/preProcessPattern.js index 45fa6bc7..ec7e286d 100644 --- a/src/preProcessPattern.js +++ b/src/preProcessPattern.js @@ -46,7 +46,8 @@ export default function preProcessPattern(globalRef, pattern) { delete fromArgs.glob; pattern.fromArgs = fromArgs; - pattern.absoluteFrom = escape(pattern.context, pattern.from.glob); + pattern.glob = escape(pattern.context, pattern.from.glob); + pattern.absoluteFrom = path.resolve(pattern.context, pattern.from.glob); return Promise.resolve(pattern); } @@ -63,7 +64,7 @@ export default function preProcessPattern(globalRef, pattern) { // If from doesn't appear to be a glob, then log a warning if (isGlob(pattern.from) || pattern.from.indexOf('*') !== -1) { pattern.fromType = 'glob'; - pattern.absoluteFrom = escape(pattern.context, pattern.from); + pattern.glob = escape(pattern.context, pattern.from); } else { const msg = `unable to locate '${pattern.from}' at '${pattern.absoluteFrom}'`; warning(msg); @@ -80,14 +81,15 @@ export default function preProcessPattern(globalRef, pattern) { pattern.fromType = 'dir'; pattern.context = pattern.absoluteFrom; contextDependencies.push(pattern.absoluteFrom); - pattern.absoluteFrom = escape(pattern.absoluteFrom, '**/*'); + pattern.glob = escape(pattern.absoluteFrom, '**/*'); + pattern.absoluteFrom = path.join(pattern.absoluteFrom, '**/*'); pattern.fromArgs = { dot: true }; } else if(stat.isFile()) { pattern.fromType = 'file'; pattern.context = path.dirname(pattern.absoluteFrom); - pattern.absoluteFrom = escape(pattern.absoluteFrom); + pattern.glob = escape(pattern.absoluteFrom); pattern.fromArgs = { dot: true }; diff --git a/src/processPattern.js b/src/processPattern.js index 72833429..626bba52 100644 --- a/src/processPattern.js +++ b/src/processPattern.js @@ -17,8 +17,8 @@ export default function processPattern(globalRef, pattern) { const limit = pLimit(concurrency || 100); - info(`begin globbing '${pattern.absoluteFrom}' with a context of '${pattern.context}'`); - return globby(pattern.absoluteFrom, globArgs) + info(`begin globbing '${pattern.glob}' with a context of '${pattern.context}'`); + return globby(pattern.glob, globArgs) .then((paths) => Promise.all(paths.map((from) => limit(() => { const file = { force: pattern.force,