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

Update watched file list when files are added or removed #1539

Merged
merged 1 commit into from
May 10, 2016
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
30 changes: 23 additions & 7 deletions bin/node-sass
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand All @@ -260,6 +268,14 @@ function watch(options, emitter) {
}
});
});

gaze.on('added', function(file) {
graph = buildGraph(options);
});

gaze.on('deleted', function(file) {
graph = buildGraph(options);
});
}

/**
Expand Down