Skip to content
This repository was archived by the owner on Jul 24, 2024. It is now read-only.

Commit a3ae966

Browse files
authored
Merge pull request #2151 from sass/more-watcher-fixes
Fix watching of entry points
2 parents e3ca075 + 2326b5f commit a3ae966

File tree

7 files changed

+443
-118
lines changed

7 files changed

+443
-118
lines changed

bin/node-sass

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -250,8 +250,6 @@ function watch(options, emitter) {
250250
});
251251
};
252252

253-
watcher.reset(options);
254-
255253
var gaze = new Gaze();
256254
gaze.add(watcher.reset(options));
257255
gaze.on('error', emitter.emit.bind(emitter, 'error'));

lib/watcher.js

Lines changed: 12 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
var grapher = require('sass-graph'),
22
clonedeep = require('lodash.clonedeep'),
3+
path = require('path'),
34
config = {},
45
watcher = {},
56
graph = null;
@@ -30,8 +31,14 @@ watcher.changed = function(absolutePath) {
3031

3132
this.reset();
3233

34+
if (absolutePath && path.basename(absolutePath)[0] !== '_') {
35+
files.changed.push(absolutePath);
36+
}
37+
3338
graph.visitAncestors(absolutePath, function(parent) {
34-
files.changed.push(parent);
39+
if (path.basename(parent)[0] !== '_') {
40+
files.changed.push(parent);
41+
}
3542
});
3643

3744
graph.visitDescendents(absolutePath, function(child) {
@@ -50,7 +57,7 @@ watcher.added = function(absolutePath) {
5057

5158
this.reset();
5259

53-
if (Object.keys(graph.index).indexOf(absolutePath) !== -1) {
60+
if (Object.keys(graph.index).indexOf(absolutePath) === -1) {
5461
files.added.push(absolutePath);
5562
}
5663

@@ -69,7 +76,9 @@ watcher.removed = function(absolutePath) {
6976
};
7077

7178
graph.visitAncestors(absolutePath, function(parent) {
72-
files.changed.push(parent);
79+
if (path.basename(parent)[0] !== '_') {
80+
files.changed.push(parent);
81+
}
7382
});
7483

7584
if (Object.keys(graph.index).indexOf(absolutePath) !== -1) {
Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,5 @@
1+
@import "partials/three";
2+
13
.one {
24
color: darkred;
35
}
Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,5 @@
1+
@import "partials/three";
2+
13
.two {
24
color: darkblue;
35
}

test/fixtures/watcher/main/three.scss

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
.three {
2+
color: green;
3+
}

test/fixtures/watcher/main/two.scss

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,3 @@
1-
@import "partials/two";
2-
31
.two {
42
color: blue;
53
}

0 commit comments

Comments
 (0)