Skip to content

Commit

Permalink
Merge pull request #2246 from sass/deprecation-cli
Browse files Browse the repository at this point in the history
Fix deprecation flags in the CLI and add tests
  • Loading branch information
nex3 authored May 15, 2024
2 parents 54a6dec 9a9e483 commit bdc08fd
Show file tree
Hide file tree
Showing 10 changed files with 570 additions and 7 deletions.
9 changes: 9 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,3 1,12 @@
## 1.77.2

### Command-Line Interface

* Properly handle the `--silence-deprecation` flag.

* Handle the `--fatal-deprecation` and `--future-deprecation` flags for
`--interactive` mode.

## 1.77.1

* Fix a crash that could come up with importers in certain contexts.
Expand Down
4 changes: 4 additions & 0 deletions lib/src/executable/compile_stylesheet.dart
Original file line number Diff line number Diff line change
Expand Up @@ -110,6 110,7 @@ Future<void> _compileStylesheetWithoutErrorHandling(ExecutableOptions options,
verbose: options.verbose,
sourceMap: options.emitSourceMap,
charset: options.charset,
silenceDeprecations: options.silenceDeprecations,
fatalDeprecations: options.fatalDeprecations,
futureDeprecations: options.futureDeprecations)
: await compileAsync(source,
Expand All @@ -121,6 122,7 @@ Future<void> _compileStylesheetWithoutErrorHandling(ExecutableOptions options,
verbose: options.verbose,
sourceMap: options.emitSourceMap,
charset: options.charset,
silenceDeprecations: options.silenceDeprecations,
fatalDeprecations: options.fatalDeprecations,
futureDeprecations: options.futureDeprecations);
} else {
Expand All @@ -135,6 137,7 @@ Future<void> _compileStylesheetWithoutErrorHandling(ExecutableOptions options,
verbose: options.verbose,
sourceMap: options.emitSourceMap,
charset: options.charset,
silenceDeprecations: options.silenceDeprecations,
fatalDeprecations: options.fatalDeprecations,
futureDeprecations: options.futureDeprecations)
: compile(source,
Expand All @@ -146,6 149,7 @@ Future<void> _compileStylesheetWithoutErrorHandling(ExecutableOptions options,
verbose: options.verbose,
sourceMap: options.emitSourceMap,
charset: options.charset,
silenceDeprecations: options.silenceDeprecations,
fatalDeprecations: options.fatalDeprecations,
futureDeprecations: options.futureDeprecations);
}
Expand Down
12 changes: 9 additions & 3 deletions lib/src/executable/repl.dart
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 12,7 @@ import '../exception.dart';
import '../executable/options.dart';
import '../import_cache.dart';
import '../importer/filesystem.dart';
import '../logger/deprecation_processing.dart';
import '../logger/tracking.dart';
import '../parse/parser.dart';
import '../utils.dart';
Expand All @@ -20,7 21,12 @@ import '../visitor/evaluate.dart';
/// Runs an interactive SassScript shell according to [options].
Future<void> repl(ExecutableOptions options) async {
var repl = Repl(prompt: '>> ');
var logger = TrackingLogger(options.logger);
var trackingLogger = TrackingLogger(options.logger);
var logger = DeprecationProcessingLogger(trackingLogger,
silenceDeprecations: options.silenceDeprecations,
fatalDeprecations: options.fatalDeprecations,
futureDeprecations: options.futureDeprecations,
limitRepetition: !options.verbose);
var evaluator = Evaluator(
importer: FilesystemImporter.cwd,
importCache: ImportCache(
Expand All @@ -46,8 52,8 @@ Future<void> repl(ExecutableOptions options) async {
print(evaluator.evaluate(Expression.parse(line, logger: logger)));
}
} on SassException catch (error, stackTrace) {
_logError(
error, getTrace(error) ?? stackTrace, line, repl, options, logger);
_logError(error, getTrace(error) ?? stackTrace, line, repl, options,
trackingLogger);
}
}
}
Expand Down
4 changes: 4 additions & 0 deletions pkg/sass_api/CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,3 1,7 @@
## 10.4.2

* No user-visible changes.

## 10.4.1

* No user-visible changes.
Expand Down
6 changes: 3 additions & 3 deletions pkg/sass_api/pubspec.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -2,18 2,18 @@ name: sass_api
# Note: Every time we add a new Sass AST node, we need to bump the *major*
# version because it's a breaking change for anyone who's implementing the
# visitor interface(s).
version: 10.4.1
version: 10.4.2
description: Additional APIs for Dart Sass.
homepage: https://github.com/sass/dart-sass

environment:
sdk: ">=3.0.0 <4.0.0"

dependencies:
sass: 1.77.1
sass: 1.77.2

dev_dependencies:
dartdoc: ^6.0.0
dartdoc: ">=6.0.0 <9.0.0"

dependency_overrides:
sass: { path: ../.. }
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.77.1
version: 1.77.2
description: A Sass implementation in Dart.
homepage: https://github.com/sass/dart-sass

Expand Down
15 changes: 15 additions & 0 deletions test/cli/dart/deprecations_test.dart
Original file line number Diff line number Diff line change
@@ -0,0 1,15 @@
// Copyright 2024 Google Inc. Use of this source code is governed by an
// MIT-style license that can be found in the LICENSE file or at
// https://opensource.org/licenses/MIT.

@TestOn('vm')

import 'package:test/test.dart';

import '../dart_test.dart';
import '../shared/deprecations.dart';

void main() {
setUpAll(ensureSnapshotUpToDate);
sharedTests(runSass);
}
17 changes: 17 additions & 0 deletions test/cli/node/deprecations_test.dart
Original file line number Diff line number Diff line change
@@ -0,0 1,17 @@
// Copyright 2024 Google Inc. Use of this source code is governed by an
// MIT-style license that can be found in the LICENSE file or at
// https://opensource.org/licenses/MIT.

@TestOn('vm')
@Tags(['node'])

import 'package:test/test.dart';

import '../../ensure_npm_package.dart';
import '../node_test.dart';
import '../shared/deprecations.dart';

void main() {
setUpAll(ensureNpmPackage);
sharedTests(runSass);
}
Loading

0 comments on commit bdc08fd

Please sign in to comment.