Skip to content

Commit 6d3d928

Browse files
authored
Delete source maps when source files are deleted in watch mode (#2626)
Closes #2613
1 parent c61b098 commit 6d3d928

File tree

4 files changed

+33
-2
lines changed

4 files changed

+33
-2
lines changed

CHANGELOG.md

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,11 @@
33
* Fix a bug where `@extend` rules loaded through a mixture of `@import` and
44
`@use` rules could fail to apply correctly.
55

6+
### Command-Line Interface
7+
8+
* In `--watch` mode, delete the source map when the associated source file is
9+
deleted.
10+
611
## 1.91.0
712

813
* **Potentially breaking change:** `meta.inspect()` (as well as other systems

lib/src/executable/watch.dart

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -166,7 +166,10 @@ final class _Watcher {
166166
var url = _canonicalize(path);
167167

168168
if (_graph.nodes.containsKey(url)) {
169-
if (_destinationFor(path) case var destination?) _delete(destination);
169+
if (_destinationFor(path) case var destination?) {
170+
_delete(destination);
171+
_delete("$destination.map");
172+
}
170173
}
171174

172175
var downstream = _graph.remove(FilesystemImporter.cwd, url);

pkg/sass_api/pubspec.yaml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@ environment:
1010
sdk: ">=3.6.0 <4.0.0"
1111

1212
dependencies:
13-
sass: 1.91.1
13+
sass: 1.91.1-dev
1414

1515
dev_dependencies:
1616
dartdoc: ^8.0.14

test/cli/shared/watch.dart

Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -976,6 +976,29 @@ void sharedTests(Future<TestProcess> runSass(Iterable<String> arguments)) {
976976

977977
await d.dir("dir", [d.nothing("out.css")]).validate();
978978
});
979+
980+
test("and deletes the source map", () async {
981+
await d.file("test.scss", "a {b: c}").create();
982+
983+
var sass = await watch(["--source-map", "test.scss:out.css"]);
984+
await expectLater(
985+
sass.stdout,
986+
emits(endsWith('Compiled test.scss to out.css.')),
987+
);
988+
await expectLater(sass.stdout, _watchingForChanges);
989+
await tickIfPoll();
990+
991+
d.file("test.scss").io.deleteSync();
992+
await expectLater(
993+
sass.stdout,
994+
emitsInOrder([
995+
'Deleted out.css.',
996+
'Deleted out.css.map.',
997+
]));
998+
await sass.kill();
999+
1000+
await d.nothing("out.css").validate();
1001+
});
9791002
});
9801003

9811004
test("creates a new CSS file when a Sass file is added", () async {

0 commit comments

Comments
 (0)