Skip to content

Commit

Permalink
fix(src/): don't escape non-glob patterns (#230)
Browse files Browse the repository at this point in the history
  • Loading branch information
evilebottnawi authored and michael-ciniawsky committed Feb 23, 2018
1 parent 4e15c1c commit 0eb2cd5
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 6 deletions.
10 changes: 6 additions & 4 deletions src/preProcessPattern.js
Original file line number Diff line number Diff line change
Expand Up @@ -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);
}

Expand All @@ -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);
Expand All @@ -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
};
Expand Down
4 changes: 2 additions & 2 deletions src/processPattern.js
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down

0 comments on commit 0eb2cd5

Please sign in to comment.