Skip to content

Commit

Permalink
Use sass-graph for accurate sass watching
Browse files Browse the repository at this point in the history
  • Loading branch information
xzyfer committed Jan 15, 2015
1 parent fda34ba commit 91d26b8
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 3 deletions.
18 changes: 15 additions & 3 deletions bin/node-sass
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ var Emitter = require('events').EventEmitter,
meow = require('meow'),
replaceExt = require('replace-ext'),
stdin = require('get-stdin'),
grapher = require('sass-graph'),
render = require('../lib/render');

/**
Expand Down Expand Up @@ -183,10 +184,21 @@ function watch(options, emitter) {
gaze.add(dir);
gaze.on('error', emitter.emit.bind(emitter, 'error'));

var graph = grapher.parseDir(options.src, { loadPaths: options.includePath });

gaze.on('changed', function(file) {
options = getOptions([file], options);
emitter.emit('warn', '=> changed: ' + file);
render(options, emitter);
var files = [];
graph.visitAncestors(file, function(parent) {
if (path.basename(parent)[0] !== '_') {
files.push(parent);
}
});

files.forEach(function(file) {
options = getOptions([path.resolve(file)], options);
emitter.emit('warn', '=> changed: ' + file);
render(options, emitter);
});
});
}

Expand Down
1 change: 1 addition & 0 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -55,6 +55,7 @@
"object-assign": "^2.0.0",
"replace-ext": "0.0.1",
"request": "^2.48.0",
"sass-graph": "^1.0.0",
"shelljs": "^0.3.0"
},
"devDependencies": {
Expand Down

0 comments on commit 91d26b8

Please sign in to comment.