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

Commit

Permalink
Fix watching of CSS files to avoid infinite build cycle
Browse files Browse the repository at this point in the history
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.
  • Loading branch information
Nateowami committed Mar 15, 2017
1 parent f2f4b96 commit 487c885
Showing 1 changed file with 4 additions and 1 deletion.
5 changes: 4 additions & 1 deletion bin/node-sass
Original file line number Diff line number Diff line change
Expand Up @@ -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);
}
});
Expand Down Expand Up @@ -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') {
Expand Down

0 comments on commit 487c885

Please sign in to comment.