From 487c885411a26c3d27ee8709824de1d500fc7c14 Mon Sep 17 00:00:00 2001 From: Nathaniel Paulus Date: Tue, 14 Mar 2017 17:04:28 +0700 Subject: [PATCH] Fix watching of CSS files to avoid infinite build cycle Previously when the src and dest dirs were the same, whenever a CSS file changed (either manually or as the result of a build) it was recursively recompiled in an infinite loop, unless a build finished in less than 500ms (Gaze's default file watching debounce). Now, when the input and output dirs are the same, CSS files are treated like includes (files starting with an underscore) in that they are never built into CSS, but they are watched in case they are included in a Sass file. When the input and output dirs differ, functionality is unchanged. --- bin/node-sass | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/bin/node-sass b/bin/node-sass index e94c12c77..4267d36db 100755 --- a/bin/node-sass +++ b/bin/node-sass @@ -274,7 +274,8 @@ function watch(options, emitter) { } }); files.forEach(function(file) { - if (path.basename(file)[0] !== '_') { + var fileName = path.basename(file); + if (fileName[0] !== '_' && (!options.sameInputAsOutput || fileName.slice(-4) !== '.css')) { renderFile(file, options, emitter); } }); @@ -309,6 +310,8 @@ function run(options, emitter) { if (!isDirectory(options.output)) { emitter.emit('error', 'An output directory must be specified when compiling a directory'); } + + options.sameInputAsOutput = path.resolve(options.directory) === path.resolve(options.output); } if (options.sourceMapOriginal && options.directory && !isDirectory(options.sourceMapOriginal) && options.sourceMapOriginal !== 'true') {