Skip to content

Commit e0ebc4c

Browse files
committed
Fix bug with string passed as files
1 parent 7142cae commit e0ebc4c

File tree

4 files changed

+34
-3
lines changed

4 files changed

+34
-3
lines changed

CHANGELOG.md

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,10 @@ Latest version of this document will always be available on https://github.com/S
77
## [Unreleased]
88
Nothing
99

10+
## [2.0.1] - 2017-04-23
11+
### Fixes
12+
- Support only string as option to files
13+
1014
## [2.0.0] - 2017-04-23
1115
### Breaking
1216
- Drop support for `node<4`

__snapshots__/test.js.snap

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,15 @@ Object {
1616
}
1717
`;
1818

19+
exports[`filter option should include some files with string option 1`] = `
20+
Object {
21+
"css": Array [],
22+
"js": Array [
23+
"vendor/my-file.js",
24+
],
25+
}
26+
`;
27+
1928
exports[`should add file missing "/" to public path 1`] = `
2029
Object {
2130
"css": Array [],

src/addAllAssetsToCompilation.js

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -39,10 +39,10 @@ async function addFileToAssets(
3939
return Promise.reject(error);
4040
}
4141

42-
const filters = Array.isArray(files) ? files : [files];
42+
const fileFilters = Array.isArray(files) ? files : [files];
4343

44-
if (filters.length > 0) {
45-
const shouldSkip = !files.some(file => minimatch(htmlPluginData.outputName, file));
44+
if (fileFilters.length > 0) {
45+
const shouldSkip = !fileFilters.some(file => minimatch(htmlPluginData.outputName, file));
4646

4747
if (shouldSkip) {
4848
return Promise.resolve(null);

test.js

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -228,3 +228,21 @@ test('filter option should include some files', async () => {
228228
expect(callback).toHaveBeenCalledTimes(1);
229229
expect(callback).toHaveBeenCalledWith(null, pluginData);
230230
});
231+
232+
test('filter option should include some files with string option', async () => {
233+
const callback = jest.fn();
234+
const compilation = { options: { output: { publicPath: 'vendor/' } } };
235+
const pluginData = Object.assign({ assets: { js: [], css: [] } }, pluginMock);
236+
237+
await addAllAssetsToCompilation(
238+
[{ filepath: path.join(__dirname, 'my-file.js'), files: 'index.*' }],
239+
compilation,
240+
pluginData,
241+
callback
242+
);
243+
244+
expect(pluginData.assets).toMatchSnapshot();
245+
246+
expect(callback).toHaveBeenCalledTimes(1);
247+
expect(callback).toHaveBeenCalledWith(null, pluginData);
248+
});

0 commit comments

Comments
 (0)