Skip to content

Commit

Permalink
fix: Fixed glob as object
Browse files Browse the repository at this point in the history
Resolves: #87
  • Loading branch information
kevlened authored and joshwiens committed Sep 29, 2017
1 parent ad62899 commit 1b2c21a
Show file tree
Hide file tree
Showing 2 changed files with 23 additions and 0 deletions.
8 changes: 8 additions & 0 deletions src/preProcessPattern.js
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,14 @@ export default function preProcessPattern(globalRef, pattern) {

debug(`determined '${pattern.to}' is a '${pattern.toType}'`);

// If we know it's a glob, then bail early
if (_.isObject(pattern.from) && pattern.from.glob) {
pattern.fromType = 'glob';
pattern.fromArgs = _.omit(pattern.from, ['glob']);
pattern.absoluteFrom = path.resolve(pattern.context, pattern.from.glob);
return Promise.resolve(pattern);
}

if (path.isAbsolute(pattern.from)) {
pattern.absoluteFrom = pattern.from;
} else {
Expand Down
15 changes: 15 additions & 0 deletions tests/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -209,6 +209,21 @@ describe('apply function', () => {
.catch(done);
});

it('can use a glob object to move a file to the root directory', (done) => {
runEmit({
expectedAssetKeys: [
'file.txt'
],
patterns: [{
from: {
glob: '*.txt'
}
}]
})
.then(done)
.catch(done);
});

it('can use a glob to move multiple files to the root directory', (done) => {
runEmit({
expectedAssetKeys: [
Expand Down

0 comments on commit 1b2c21a

Please sign in to comment.