Skip to content

Commit

Permalink
Fix a check that prevents compiling .css files to themselves (#968)
Browse files Browse the repository at this point in the history
Co-Authored-By: Natalie Weizenbaum <[email protected]>
  • Loading branch information
georgpukk and nex3 committed Mar 11, 2020
1 parent cf43f0d commit 4d78316
Show file tree
Hide file tree
Showing 4 changed files with 35 additions and 2 deletions.
5 changes: 5 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -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
Expand Down
2 changes: 1 addition & 1 deletion lib/src/executable/watch.dart
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down
2 changes: 1 addition & 1 deletion pubspec.yaml
Original file line number Diff line number Diff line change
@@ -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
Expand Down
28 changes: 28 additions & 0 deletions test/cli/shared/watch.dart
Original file line number Diff line number Diff line change
Expand Up @@ -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();
Expand Down

0 comments on commit 4d78316

Please sign in to comment.