Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix(preProcessPattern): throw an {Error} if pattern.from is empty or undefined #285

Merged
merged 2 commits into from Dec 20, 2018
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
3 changes: 3 additions & 0 deletions src/preProcessPattern.js
Expand Up @@ -14,6 +14,9 @@ export default function preProcessPattern(globalRef, pattern) {
pattern = typeof pattern === 'string' ? {
from: pattern
} : Object.assign({}, pattern);
if (pattern.from === '') {
Deliaz marked this conversation as resolved.
Show resolved Hide resolved
throw new Error('[copy-webpack-plugin] path "from" cannot be empty string');
}
pattern.to = pattern.to || '';
pattern.context = pattern.context || context;
if (!path.isAbsolute(pattern.context)) {
Expand Down
12 changes: 11 additions & 1 deletion tests/index.js
Expand Up @@ -227,6 +227,16 @@ describe('apply function', () => {

expect(createPluginWithNull).to.throw(Error);
});

it('throws an error if the "from" path is an empty string', () => {
const createPluginWithNull = () => {
CopyWebpackPlugin({
from: ''
});
};

expect(createPluginWithNull).to.throw(Error);
});
});

describe('with glob in from', () => {
Expand Down Expand Up @@ -1434,7 +1444,7 @@ describe('apply function', () => {
patterns: [{
from: '.'
}]

})
.then(done)
.catch(done);
Expand Down