Skip to content

Commit

Permalink
Merge pull request #629 from xzyfer/feat/better-watcher-compilation-t…
Browse files Browse the repository at this point in the history
…argets

Use sass-graph for accurate sass watching
  • Loading branch information
xzyfer committed Jan 15, 2015
2 parents c9e3eaa + fa13e98 commit 604ccf5
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 3 deletions.
17 changes: 14 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 @@ -173,10 +174,20 @@ 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 = [file];
graph.visitAncestors(file, function(parent) {
files.push(parent);
});

files.forEach(function(file) {
if (path.basename(file)[0] === '_') return;
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.1",
"shelljs": "^0.3.0"
},
"devDependencies": {
Expand Down

0 comments on commit 604ccf5

Please sign in to comment.