Skip to content

Commit

Permalink
fix: throw error if "from" is an empty string #278 (#285)
Browse files Browse the repository at this point in the history
  • Loading branch information
Deliaz authored and evilebottnawi committed Dec 20, 2018
1 parent bf6713d commit adf1046
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 1 deletion.
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 === '') {
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 @@ -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

0 comments on commit adf1046

Please sign in to comment.