Skip to content
New issue

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

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

Already on GitHub? # 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 all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 3 additions & 0 deletions src/preProcessPattern.js
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,9 @@ export default function preProcessPattern(globalRef, pattern) {
pattern = typeof pattern === 'string' ? {
from: pattern
} : Object.assign({}, pattern);
if (pattern.from === '') {
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
Original file line number Diff line number Diff line change
Expand Up @@ -236,6 +236,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 @@ -1615,7 +1625,7 @@ describe('apply function', () => {
patterns: [{
from: '.'
}]

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