Skip to content

Commit 056a60b

Browse files
committed
feat: Support simple string patterns
Fixes #150
1 parent d49c989 commit 056a60b

File tree

2 files changed

+22
-1
lines changed

2 files changed

+22
-1
lines changed

src/preProcessPattern.js

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,9 @@ export default function preProcessPattern(globalRef, pattern) {
1212
const {info, debug, warning, context,
1313
fileDependencies, contextDependencies, compilation} = globalRef;
1414

15-
pattern = _.cloneDeep(pattern);
15+
pattern = typeof pattern === 'string' ? {
16+
from: pattern
17+
} : _.cloneDeep(pattern);
1618
pattern.to = pattern.to || '';
1719
pattern.context = pattern.context || context;
1820
if (!path.isAbsolute(pattern.context)) {

tests/index.js

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1053,6 +1053,25 @@ describe('apply function', () => {
10531053
});
10541054
});
10551055

1056+
describe('with simple string patterns', () => {
1057+
it('can move multiple files', (done) => {
1058+
runEmit({
1059+
expectedAssetKeys: [
1060+
'binextension.bin',
1061+
'file.txt',
1062+
'noextension'
1063+
],
1064+
patterns: [
1065+
'binextension.bin',
1066+
'file.txt',
1067+
'noextension'
1068+
]
1069+
})
1070+
.then(done)
1071+
.catch(done);
1072+
});
1073+
});
1074+
10561075
describe('options', () => {
10571076
describe('ignore', () => {
10581077
it('ignores files when from is a file', (done) => {

0 commit comments

Comments
 (0)