From 3046385f222514f76362ec69ea3236d96c5059e3 Mon Sep 17 00:00:00 2001 From: Natalie Weizenbaum Date: Tue, 15 Jun 2021 13:14:12 -0700 Subject: [PATCH] Fix quiet deps when loaded through an @import of a file without @use Closes #1360 --- CHANGELOG.md | 5 +++++ lib/src/visitor/async_evaluate.dart | 3 +++ lib/src/visitor/evaluate.dart | 5 ++++- pubspec.yaml | 2 +- test/cli/shared.dart | 25 +++++++++++++++++++++++++ 5 files changed, 38 insertions(+), 2 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index b7f347b3c..5808078ff 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,3 +1,8 @@ +## 1.35.1 + +* Fix a bug where the quiet dependency flag didn't silence warnings in some + stylesheets loaded using `@import`. + ## 1.35.0 * Fix a couple bugs that could prevent some members from being found in certain diff --git a/lib/src/visitor/async_evaluate.dart b/lib/src/visitor/async_evaluate.dart index b32546075..427758e27 100644 --- a/lib/src/visitor/async_evaluate.dart +++ b/lib/src/visitor/async_evaluate.dart @@ -1480,11 +1480,14 @@ class _EvaluateVisitor if (stylesheet.uses.isEmpty && stylesheet.forwards.isEmpty) { var oldImporter = _importer; var oldStylesheet = _stylesheet; + var oldInDependency = _inDependency; _importer = result.importer; _stylesheet = stylesheet; + _inDependency = result.isDependency; await visitStylesheet(stylesheet); _importer = oldImporter; _stylesheet = oldStylesheet; + _inDependency = oldInDependency; _activeModules.remove(url); return; } diff --git a/lib/src/visitor/evaluate.dart b/lib/src/visitor/evaluate.dart index fa49cd546..97bf85ad3 100644 --- a/lib/src/visitor/evaluate.dart +++ b/lib/src/visitor/evaluate.dart @@ -5,7 +5,7 @@ // DO NOT EDIT. This file was generated from async_evaluate.dart. // See tool/grind/synchronize.dart for details. // -// Checksum: 203ba98fd9ca92ccc0b6465fd0d617e88c8dd37e +// Checksum: 1249b1184a46950409776772cb1c6003b80ebb31 // // ignore_for_file: unused_import @@ -1479,11 +1479,14 @@ class _EvaluateVisitor if (stylesheet.uses.isEmpty && stylesheet.forwards.isEmpty) { var oldImporter = _importer; var oldStylesheet = _stylesheet; + var oldInDependency = _inDependency; _importer = result.importer; _stylesheet = stylesheet; + _inDependency = result.isDependency; visitStylesheet(stylesheet); _importer = oldImporter; _stylesheet = oldStylesheet; + _inDependency = oldInDependency; _activeModules.remove(url); return; } diff --git a/pubspec.yaml b/pubspec.yaml index 304603698..4a8fd35f8 100644 --- a/pubspec.yaml +++ b/pubspec.yaml @@ -1,5 +1,5 @@ name: sass -version: 1.35.0 +version: 1.35.1 description: A Sass implementation in Dart. author: Sass Team homepage: https://github.com/sass/dart-sass diff --git a/test/cli/shared.dart b/test/cli/shared.dart index 5625eeab5..560d7a96c 100644 --- a/test/cli/shared.dart +++ b/test/cli/shared.dart @@ -481,6 +481,31 @@ void sharedTests( await sass.shouldExit(0); }); }); + + group("silences warnings through @import", () { + test("of a file without @use", () async { + await d.file("test.scss", "@import 'other'").create(); + await d.dir("dir", [d.file("_other.scss", "#{blue} {x: y}")]).create(); + + var sass = await runSass(["--quiet-deps", "-I", "dir", "test.scss"]); + expect(sass.stderr, emitsDone); + await sass.shouldExit(0); + }); + + test("of a file with @use", () async { + await d.file("test.scss", "@import 'other'").create(); + await d.dir("dir", [ + d.file("_other.scss", """ + @use 'sass:color'; + #{blue} {x: y} + """) + ]).create(); + + var sass = await runSass(["--quiet-deps", "-I", "dir", "test.scss"]); + expect(sass.stderr, emitsDone); + await sass.shouldExit(0); + }); + }); }); group("with a bunch of deprecation warnings", () {