Skip to content

Commit

Permalink
fix(processPattern): don't add 'glob' as directory when it is a fil…
Browse files Browse the repository at this point in the history
…e (`contextDependencies`) (#296)
  • Loading branch information
alan-agius4 authored and michael-ciniawsky committed Oct 18, 2018
1 parent 48bc708 commit 5670926
Show file tree
Hide file tree
Showing 2 changed files with 17 additions and 1 deletion.
3 changes: 2 additions & 1 deletion src/processPattern.js
@@ -1,5 +1,6 @@
import globby from 'globby';
import pLimit from 'p-limit';
import isGlob from 'is-glob';
import path from 'path';
import minimatch from 'minimatch';
import writeFile from './writeFile';
Expand Down Expand Up @@ -33,7 +34,7 @@ export default function processPattern(globalRef, pattern) {
// This is so webpack is able to watch the directory and when
// a new file is added it triggeres a rebuild
const contextPath = path.dirname(path.resolve(from));
if (contextDependencies.indexOf(contextPath) === -1) {
if (contextDependencies.indexOf(contextPath) === -1 && isGlob(pattern.glob)) {
contextDependencies.push(contextPath);
}

Expand Down
15 changes: 15 additions & 0 deletions tests/index.js
Expand Up @@ -488,6 +488,21 @@ describe('apply function', () => {
.catch(done);
});

it('does not add the directory to the watch list when glob is a file', (done) => {
run({
patterns: [{
from: {
glob: 'directory/directoryfile.txt'
}
}]
})
.then((compilation) => {
const absFrom = path.resolve(HELPER_DIR, 'directory');
expect(compilation.contextDependencies).to.not.have.members([absFrom]);
})
.then(done)
.catch(done);
});
});

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

0 comments on commit 5670926

Please sign in to comment.