Skip to content

Commit 4ab0464

Browse files
committed
fix(stream): Allow paths with dots when apply match filter - fixes #894
1 parent 48fd16c commit 4ab0464

File tree

3 files changed

+31
-6
lines changed

3 files changed

+31
-6
lines changed

lib/public/stream.js

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,8 @@
11
"use strict";
22

3-
var path = require("path");
4-
var anymatch = require("anymatch");
5-
var utils = require("./public-utils");
3+
var path = require("path");
4+
var micromatch = require("micromatch");
5+
var utils = require("./public-utils");
66

77
/**
88
* @param emitter
@@ -43,7 +43,7 @@ module.exports = function (emitter) {
4343
* current filepath against it
4444
*/
4545
if (opts.match) {
46-
if (!anymatch(opts.match, file.path)) {
46+
if (!micromatch(file.path, opts.match, {dot: true}).length) {
4747
return end();
4848
}
4949
}

package.json

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -30,12 +30,11 @@
3030
"pre-release": "npm test && npm run pro-local && npm run pro"
3131
},
3232
"dependencies": {
33-
"anymatch": "^1.3.0",
3433
"async-each-series": "^0.1.1",
3534
"browser-sync-client": "^2.3.3",
3635
"browser-sync-ui": "^0.5.16",
3736
"bs-recipes": "^1.0.5",
38-
"chokidar": "^1.0.5",
37+
"chokidar": "1.4.1",
3938
"connect": "^3.4.0",
4039
"dev-ip": "^1.0.1",
4140
"easy-extender": "^2.3.1",
@@ -48,6 +47,7 @@
4847
"lodash": "^3.9.3",
4948
"longest": "^1.0.1",
5049
"meow": "3.3.0",
50+
"micromatch": "2.3.5",
5151
"opn": "^3.0.2",
5252
"portscanner": "^1.0.0",
5353
"query-string": "^2.4.0",

test/specs/api/init.reload.stream.js

Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -113,6 +113,31 @@ describe("API: .stream()", function () {
113113
clock.tick();
114114
sinon.assert.notCalled(emitterStub);
115115
});
116+
it("accepts file paths beginning with dots", function () {
117+
var stream = browserSync.stream({match: "**/*.css"});
118+
stream.write(new File({path: "/users/shakyshane/.tmp/css/core.css"}));
119+
stream.write(new File({path: "/users/shakyshane/.tmp/css/core.css.map"}));
120+
stream.end();
121+
clock.tick();
122+
sinon.assert.calledWithExactly(emitterStub, "file:changed", {
123+
path: "/users/shakyshane/.tmp/css/core.css",
124+
basename: "core.css",
125+
log: false,
126+
namespace: "core",
127+
event: "change",
128+
ext: "css"
129+
});
130+
sinon.assert.calledWithExactly(emitterStub, "file:reload", {
131+
ext: "css",
132+
path: "/users/shakyshane/.tmp/css/core.css",
133+
basename: "core.css",
134+
type: "inject",
135+
log: false
136+
});
137+
sinon.assert.calledWithExactly(emitterStub, "stream:changed", {
138+
changed: ["core.css"]
139+
});
140+
});
116141
it("emits the stream:changed event with an array of changed files", function () {
117142

118143
var stream = browserSync.stream();

0 commit comments

Comments
 (0)