Fix a check that prevents compiling .css files to themselves (#968)

Co-Authored-By: Natalie Weizenbaum <nweiz@google.com>
This commit is contained in:
georgpukk 2020-03-11 23:48:00 +02:00 committed by GitHub
parent cf43f0d851
commit 4d78316cb7
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
4 changed files with 35 additions and 2 deletions

View File

@ -1,3 +1,8 @@
## 1.26.3
* Fix a bug where `--watch` mode could go into an infinite loop compiling CSS
files to themselves.
## 1.26.2
* More aggressively eliminate redundant selectors in the `selector.extend()` and

View File

@ -267,7 +267,7 @@ class _Watcher {
p.setExtension(p.relative(source, from: sourceDir), '.css'));
// Don't compile ".css" files to their own locations.
if (destination != source) return destination;
if (!p.equals(destination, source)) return destination;
}
return null;

View File

@ -1,5 +1,5 @@
name: sass
version: 1.26.2
version: 1.26.3
description: A Sass implementation in Dart.
author: Sass Team
homepage: https://github.com/sass/dart-sass

View File

@ -173,6 +173,34 @@ void sharedTests(Future<TestProcess> runSass(Iterable<String> arguments)) {
]).validate();
});
test(
"when it's modified twice when watched from a directory that is "
"also a destination", () async {
await d.file("test.scss", "a {b: c}").create();
var sass = await watch(["."]);
await expectLater(
sass.stdout, emits('Compiled test.scss to test.css.'));
await expectLater(sass.stdout, _watchingForChanges);
await tickIfPoll();
await d.file("test.scss", "r {o: g}").create();
await expectLater(
sass.stdout, emits('Compiled test.scss to test.css.'));
await tickIfPoll();
await d.file("test.scss", "x {y: z}").create();
await expectLater(
sass.stdout, emits('Compiled test.scss to test.css.'));
await sass.kill();
await d
.file("test.css", equalsIgnoringWhitespace("x { y: z; }"))
.validate();
});
group("when its dependency is modified", () {
test("through @import", () async {
await d.file("_other.scss", "a {b: c}").create();