Skip to content

Commit 4d78316

Browse files
georgpukknex3
andauthored
Fix a check that prevents compiling .css files to themselves (#968)
Co-Authored-By: Natalie Weizenbaum <[email protected]>
1 parent cf43f0d commit 4d78316

File tree

4 files changed

+35
-2
lines changed

4 files changed

+35
-2
lines changed

CHANGELOG.md

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,8 @@
1+
## 1.26.3
2+
3+
* Fix a bug where `--watch` mode could go into an infinite loop compiling CSS
4+
files to themselves.
5+
16
## 1.26.2
27

38
* More aggressively eliminate redundant selectors in the `selector.extend()` and

lib/src/executable/watch.dart

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -267,7 +267,7 @@ class _Watcher {
267267
p.setExtension(p.relative(source, from: sourceDir), '.css'));
268268

269269
// Don't compile ".css" files to their own locations.
270-
if (destination != source) return destination;
270+
if (!p.equals(destination, source)) return destination;
271271
}
272272

273273
return null;

pubspec.yaml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
name: sass
2-
version: 1.26.2
2+
version: 1.26.3
33
description: A Sass implementation in Dart.
44
author: Sass Team
55
homepage: https://github.com/sass/dart-sass

test/cli/shared/watch.dart

Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -173,6 +173,34 @@ void sharedTests(Future<TestProcess> runSass(Iterable<String> arguments)) {
173173
]).validate();
174174
});
175175

176+
test(
177+
"when it's modified twice when watched from a directory that is "
178+
"also a destination", () async {
179+
await d.file("test.scss", "a {b: c}").create();
180+
181+
var sass = await watch(["."]);
182+
await expectLater(
183+
sass.stdout, emits('Compiled test.scss to test.css.'));
184+
await expectLater(sass.stdout, _watchingForChanges);
185+
await tickIfPoll();
186+
187+
await d.file("test.scss", "r {o: g}").create();
188+
await expectLater(
189+
sass.stdout, emits('Compiled test.scss to test.css.'));
190+
191+
await tickIfPoll();
192+
193+
await d.file("test.scss", "x {y: z}").create();
194+
await expectLater(
195+
sass.stdout, emits('Compiled test.scss to test.css.'));
196+
197+
await sass.kill();
198+
199+
await d
200+
.file("test.css", equalsIgnoringWhitespace("x { y: z; }"))
201+
.validate();
202+
});
203+
176204
group("when its dependency is modified", () {
177205
test("through @import", () async {
178206
await d.file("_other.scss", "a {b: c}").create();

0 commit comments

Comments
 (0)