Skip to content

Commit ddb14b2

Browse files
authored
Fix deprecation ID displays in JS mode (#2483)
In the pure JS release, these weren't working because the Dart-to-JS logger didn't know to pass along the deprecation metadata when falling back to the wrapped StderrLogger. In the embedded release, these weren't working because we didn't give it an update to match the stderr logger.
1 parent b12b508 commit ddb14b2

File tree

9 files changed

+34
-10
lines changed

9 files changed

+34
-10
lines changed

CHANGELOG.md

+6
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,9 @@
1+
## 1.83.2
2+
3+
* Properly display deprecation IDs for the JS Sass API.
4+
5+
* Don't display deprecation IDs for user-defined deprecations.
6+
17
## 1.83.1
28

39
* Fix a bug where `--quiet-deps` would get deactivated for `@content` blocks,

lib/src/embedded/logger.dart

+4
Original file line numberDiff line numberDiff line change
@@ -44,13 +44,17 @@ final class EmbeddedLogger extends LoggerWithDeprecationType {
4444
{FileSpan? span, Trace? trace, Deprecation? deprecation}) {
4545
var formatted = withGlyphs(() {
4646
var buffer = StringBuffer();
47+
var showDeprecation =
48+
deprecation != null && deprecation != Deprecation.userAuthored;
4749
if (_color) {
4850
buffer.write('\u001b[33m\u001b[1m');
4951
if (deprecation != null) buffer.write('Deprecation ');
5052
buffer.write('Warning\u001b[0m');
53+
if (showDeprecation) buffer.write(' [\u001b[34m$deprecation\u001b[0m]');
5154
} else {
5255
if (deprecation != null) buffer.write('DEPRECATION ');
5356
buffer.write('WARNING');
57+
if (showDeprecation) buffer.write(' [$deprecation]');
5458
}
5559
if (span == null) {
5660
buffer.writeln(': $message');

lib/src/logger/js_to_dart.dart

+8-2
Original file line numberDiff line numberDiff line change
@@ -41,8 +41,14 @@ final class JSToDartLogger extends LoggerWithDeprecationType {
4141
deprecationType: deprecations[deprecation?.id]));
4242
} else {
4343
_withAscii(() {
44-
_fallback.warn(message,
45-
span: span, trace: trace, deprecation: deprecation != null);
44+
switch (_fallback) {
45+
case LoggerWithDeprecationType():
46+
_fallback.internalWarn(message,
47+
span: span, trace: trace, deprecation: deprecation);
48+
case _:
49+
_fallback.warn(message,
50+
span: span, trace: trace, deprecation: deprecation != null);
51+
}
4652
});
4753
}
4854
}

lib/src/logger/stderr.dart

+4-4
Original file line numberDiff line numberDiff line change
@@ -21,18 +21,18 @@ final class StderrLogger extends LoggerWithDeprecationType {
2121
void internalWarn(String message,
2222
{FileSpan? span, Trace? trace, Deprecation? deprecation}) {
2323
var result = StringBuffer();
24+
var showDeprecation =
25+
deprecation != null && deprecation != Deprecation.userAuthored;
2426
if (color) {
2527
// Bold yellow.
2628
result.write('\u001b[33m\u001b[1m');
2729
if (deprecation != null) result.write('Deprecation ');
2830
result.write('Warning\u001b[0m');
29-
if (deprecation != null) {
30-
result.write(' [\u001b[34m$deprecation\u001b[0m]');
31-
}
31+
if (showDeprecation) result.write(' [\u001b[34m$deprecation\u001b[0m]');
3232
} else {
3333
if (deprecation != null) result.write('DEPRECATION ');
3434
result.write('WARNING');
35-
if (deprecation != null) result.write(' [$deprecation]');
35+
if (showDeprecation) result.write(' [$deprecation]');
3636
}
3737

3838
if (span == null) {

pkg/sass-parser/CHANGELOG.md

+4
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,7 @@
1+
## 0.4.10
2+
3+
* No user-visible changes.
4+
15
## 0.4.9
26

37
* Add support for parsing the `@include` rule.

pkg/sass-parser/package.json

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "sass-parser",
3-
"version": "0.4.9",
3+
"version": "0.4.10",
44
"description": "A PostCSS-compatible wrapper of the official Sass parser",
55
"repository": "sass/sass",
66
"author": "Google Inc.",

pkg/sass_api/CHANGELOG.md

+4
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,7 @@
1+
## 15.0.2
2+
3+
* No user-visible changes.
4+
15
## 15.0.1
26

37
* No user-visible changes.

pkg/sass_api/pubspec.yaml

+2-2
Original file line numberDiff line numberDiff line change
@@ -2,15 +2,15 @@ name: sass_api
22
# Note: Every time we add a new Sass AST node, we need to bump the *major*
33
# version because it's a breaking change for anyone who's implementing the
44
# visitor interface(s).
5-
version: 15.0.1
5+
version: 15.0.2
66
description: Additional APIs for Dart Sass.
77
homepage: https://github.com/sass/dart-sass
88

99
environment:
1010
sdk: ">=3.3.0 <4.0.0"
1111

1212
dependencies:
13-
sass: 1.83.1
13+
sass: 1.83.2
1414

1515
dev_dependencies:
1616
dartdoc: ^8.0.14

pubspec.yaml

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
name: sass
2-
version: 1.83.1
2+
version: 1.83.2
33
description: A Sass implementation in Dart.
44
homepage: https://github.com/sass/dart-sass
55

0 commit comments

Comments
 (0)