Skip to content

Commit 5670926

Browse files
alan-agius4michael-ciniawsky
authored andcommitted
fix(processPattern): don't add 'glob' as directory when it is a file (contextDependencies) (#296)
1 parent 48bc708 commit 5670926

File tree

2 files changed

+17
-1
lines changed

2 files changed

+17
-1
lines changed

src/processPattern.js

+2-1
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
import globby from 'globby';
22
import pLimit from 'p-limit';
3+
import isGlob from 'is-glob';
34
import path from 'path';
45
import minimatch from 'minimatch';
56
import writeFile from './writeFile';
@@ -33,7 +34,7 @@ export default function processPattern(globalRef, pattern) {
3334
// This is so webpack is able to watch the directory and when
3435
// a new file is added it triggeres a rebuild
3536
const contextPath = path.dirname(path.resolve(from));
36-
if (contextDependencies.indexOf(contextPath) === -1) {
37+
if (contextDependencies.indexOf(contextPath) === -1 && isGlob(pattern.glob)) {
3738
contextDependencies.push(contextPath);
3839
}
3940

tests/index.js

+15
Original file line numberDiff line numberDiff line change
@@ -488,6 +488,21 @@ describe('apply function', () => {
488488
.catch(done);
489489
});
490490

491+
it('does not add the directory to the watch list when glob is a file', (done) => {
492+
run({
493+
patterns: [{
494+
from: {
495+
glob: 'directory/directoryfile.txt'
496+
}
497+
}]
498+
})
499+
.then((compilation) => {
500+
const absFrom = path.resolve(HELPER_DIR, 'directory');
501+
expect(compilation.contextDependencies).to.not.have.members([absFrom]);
502+
})
503+
.then(done)
504+
.catch(done);
505+
});
491506
});
492507

493508
describe('with file in from', () => {

0 commit comments

Comments
 (0)