From 056a60bdfce199d8ae49540c3f808d0443e2c384 Mon Sep 17 00:00:00 2001 From: Clayton Watts Date: Tue, 10 Oct 2017 11:07:09 -0600 Subject: [PATCH] feat: Support simple string patterns Fixes #150 --- src/preProcessPattern.js | 4 +++- tests/index.js | 19 +++++++++++++++++++ 2 files changed, 22 insertions(+), 1 deletion(-) diff --git a/src/preProcessPattern.js b/src/preProcessPattern.js index 76c3404b..787fd91b 100644 --- a/src/preProcessPattern.js +++ b/src/preProcessPattern.js @@ -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)) { diff --git a/tests/index.js b/tests/index.js index 22810fed..3c5b9ed0 100644 --- a/tests/index.js +++ b/tests/index.js @@ -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) => {