diff --git a/bin/node-sass b/bin/node-sass index fdc9bacd9..37ac3d3ff 100755 --- a/bin/node-sass +++ b/bin/node-sass @@ -230,16 +230,24 @@ function getOptions(args, options) { */ function watch(options, emitter) { - var watch = []; + var buildGraph = function(options) { + var graphOptions = { + loadPaths: options.includePath, + extensions: ['scss', 'sass', 'css'] + }; + + if (options.directory) { + var graph = grapher.parseDir(options.directory, graphOptions); + } else { + var graph = grapher.parseFile(options.src, graphOptions); + } - var graphOptions = { loadPaths: options.includePath, extensions: ['scss', 'sass', 'css'] }; - var graph; - if (options.directory) { - graph = grapher.parseDir(options.directory, graphOptions); - } else { - graph = grapher.parseFile(options.src, graphOptions); + return graph; } + var watch = []; + var graph = buildGraph(options); + // Add all files to watch list for (var i in graph.index) { watch.push(i); @@ -260,6 +268,14 @@ function watch(options, emitter) { } }); }); + + gaze.on('added', function(file) { + graph = buildGraph(options); + }); + + gaze.on('deleted', function(file) { + graph = buildGraph(options); + }); } /**