Skip to content

Commit

Permalink
feat: Support simple string patterns
Browse files Browse the repository at this point in the history
Fixes #150
  • Loading branch information
cletusw committed Oct 10, 2017
1 parent d49c989 commit 056a60b
Show file tree
Hide file tree
Showing 2 changed files with 22 additions and 1 deletion.
4 changes: 3 additions & 1 deletion src/preProcessPattern.js
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,9 @@ export default function preProcessPattern(globalRef, pattern) {
const {info, debug, warning, context,
fileDependencies, contextDependencies, compilation} = globalRef;

pattern = _.cloneDeep(pattern);
pattern = typeof pattern === 'string' ? {
from: pattern
} : _.cloneDeep(pattern);
pattern.to = pattern.to || '';
pattern.context = pattern.context || context;
if (!path.isAbsolute(pattern.context)) {
Expand Down
19 changes: 19 additions & 0 deletions tests/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -1053,6 +1053,25 @@ describe('apply function', () => {
});
});

describe('with simple string patterns', () => {
it('can move multiple files', (done) => {
runEmit({
expectedAssetKeys: [
'binextension.bin',
'file.txt',
'noextension'
],
patterns: [
'binextension.bin',
'file.txt',
'noextension'
]
})
.then(done)
.catch(done);
});
});

describe('options', () => {
describe('ignore', () => {
it('ignores files when from is a file', (done) => {
Expand Down

0 comments on commit 056a60b

Please # to comment.