Skip to content

Commit adf1046

Browse files
Deliazevilebottnawi
authored andcommittedDec 20, 2018
fix: throw error if "from" is an empty string #278 (#285)
1 parent bf6713d commit adf1046

File tree

2 files changed

+14
-1
lines changed

2 files changed

+14
-1
lines changed
 

‎src/preProcessPattern.js

+3
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,9 @@ export default function preProcessPattern(globalRef, pattern) {
1414
pattern = typeof pattern === 'string' ? {
1515
from: pattern
1616
} : Object.assign({}, pattern);
17+
if (pattern.from === '') {
18+
throw new Error('[copy-webpack-plugin] path "from" cannot be empty string');
19+
}
1720
pattern.to = pattern.to || '';
1821
pattern.context = pattern.context || context;
1922
if (!path.isAbsolute(pattern.context)) {

‎tests/index.js

+11-1
Original file line numberDiff line numberDiff line change
@@ -236,6 +236,16 @@ describe('apply function', () => {
236236

237237
expect(createPluginWithNull).to.throw(Error);
238238
});
239+
240+
it('throws an error if the "from" path is an empty string', () => {
241+
const createPluginWithNull = () => {
242+
CopyWebpackPlugin({
243+
from: ''
244+
});
245+
};
246+
247+
expect(createPluginWithNull).to.throw(Error);
248+
});
239249
});
240250

241251
describe('with glob in from', () => {
@@ -1615,7 +1625,7 @@ describe('apply function', () => {
16151625
patterns: [{
16161626
from: '.'
16171627
}]
1618-
1628+
16191629
})
16201630
.then(done)
16211631
.catch(done);

0 commit comments

Comments
 (0)
Please sign in to comment.