Update dependencies to null-safe versions

This also replaces package_resolver with package_config, since
package_resolver is archived and is incompatible with null-safe Dart
packages.
This commit is contained in:
Jennifer Thakar 2021-03-09 14:36:48 -08:00 committed by Natalie Weizenbaum
parent 3d39f22cbf
commit 247cb3d816
13 changed files with 101 additions and 126 deletions

View File

@ -5,6 +5,7 @@
/// We strongly recommend importing this library with the prefix `sass`. /// We strongly recommend importing this library with the prefix `sass`.
library sass; library sass;
import 'package:package_config/package_config_types.dart';
import 'package:source_maps/source_maps.dart'; import 'package:source_maps/source_maps.dart';
import 'src/async_import_cache.dart'; import 'src/async_import_cache.dart';
@ -14,7 +15,6 @@ import 'src/exception.dart';
import 'src/import_cache.dart'; import 'src/import_cache.dart';
import 'src/importer.dart'; import 'src/importer.dart';
import 'src/logger.dart'; import 'src/logger.dart';
import 'src/sync_package_resolver.dart';
import 'src/syntax.dart'; import 'src/syntax.dart';
import 'src/visitor/serialize.dart'; import 'src/visitor/serialize.dart';
@ -48,11 +48,11 @@ export 'src/warn.dart' show warn;
/// * Each load path specified in the `SASS_PATH` environment variable, which /// * Each load path specified in the `SASS_PATH` environment variable, which
/// should be semicolon-separated on Windows and colon-separated elsewhere. /// should be semicolon-separated on Windows and colon-separated elsewhere.
/// ///
/// * `package:` resolution using [packageResolver], which is a /// * `package:` resolution using [packageConfig], which is a
/// [`SyncPackageResolver`][] from the `package_resolver` package. Note that /// [`PackageConfig`][] from the `package_resolver` package. Note that
/// this is a shorthand for adding a [PackageImporter] to [importers]. /// this is a shorthand for adding a [PackageImporter] to [importers].
/// ///
/// [`SyncPackageResolver`]: https://www.dartdocs.org/documentation/package_resolver/latest/package_resolver/SyncPackageResolver-class.html /// [`PackageConfig`]: https://pub.dev/documentation/package_config/latest/package_config.package_config/PackageConfig-class.html
/// ///
/// Dart functions that can be called from Sass may be passed using [functions]. /// Dart functions that can be called from Sass may be passed using [functions].
/// Each [Callable] defines a top-level function that will be invoked when the /// Each [Callable] defines a top-level function that will be invoked when the
@ -90,7 +90,7 @@ String compile(String path,
Logger logger, Logger logger,
Iterable<Importer> importers, Iterable<Importer> importers,
Iterable<String> loadPaths, Iterable<String> loadPaths,
SyncPackageResolver packageResolver, PackageConfig packageConfig,
Iterable<Callable> functions, Iterable<Callable> functions,
OutputStyle style, OutputStyle style,
void sourceMap(SingleMapping map), void sourceMap(SingleMapping map),
@ -99,9 +99,7 @@ String compile(String path,
var result = c.compile(path, var result = c.compile(path,
logger: logger, logger: logger,
importCache: ImportCache(importers, importCache: ImportCache(importers,
logger: logger, logger: logger, loadPaths: loadPaths, packageConfig: packageConfig),
loadPaths: loadPaths,
packageResolver: packageResolver),
functions: functions, functions: functions,
style: style, style: style,
sourceMap: sourceMap != null, sourceMap: sourceMap != null,
@ -132,11 +130,11 @@ String compile(String path,
/// * Each load path specified in the `SASS_PATH` environment variable, which /// * Each load path specified in the `SASS_PATH` environment variable, which
/// should be semicolon-separated on Windows and colon-separated elsewhere. /// should be semicolon-separated on Windows and colon-separated elsewhere.
/// ///
/// * `package:` resolution using [packageResolver], which is a /// * `package:` resolution using [packageConfig], which is a
/// [`SyncPackageResolver`][] from the `package_resolver` package. Note that /// [`PackageConfig`][] from the `package_resolver` package. Note that
/// this is a shorthand for adding a [PackageImporter] to [importers]. /// this is a shorthand for adding a [PackageImporter] to [importers].
/// ///
/// [`SyncPackageResolver`]: https://www.dartdocs.org/documentation/package_resolver/latest/package_resolver/SyncPackageResolver-class.html /// [`PackageConfig`]: https://pub.dev/documentation/package_config/latest/package_config.package_config/PackageConfig-class.html
/// ///
/// Dart functions that can be called from Sass may be passed using [functions]. /// Dart functions that can be called from Sass may be passed using [functions].
/// Each [Callable] defines a top-level function that will be invoked when the /// Each [Callable] defines a top-level function that will be invoked when the
@ -178,7 +176,7 @@ String compileString(String source,
bool color = false, bool color = false,
Logger logger, Logger logger,
Iterable<Importer> importers, Iterable<Importer> importers,
SyncPackageResolver packageResolver, PackageConfig packageConfig,
Iterable<String> loadPaths, Iterable<String> loadPaths,
Iterable<Callable> functions, Iterable<Callable> functions,
OutputStyle style, OutputStyle style,
@ -192,9 +190,7 @@ String compileString(String source,
syntax: syntax ?? (indented ? Syntax.sass : Syntax.scss), syntax: syntax ?? (indented ? Syntax.sass : Syntax.scss),
logger: logger, logger: logger,
importCache: ImportCache(importers, importCache: ImportCache(importers,
logger: logger, logger: logger, packageConfig: packageConfig, loadPaths: loadPaths),
packageResolver: packageResolver,
loadPaths: loadPaths),
functions: functions, functions: functions,
style: style, style: style,
importer: importer, importer: importer,
@ -214,7 +210,7 @@ Future<String> compileAsync(String path,
{bool color = false, {bool color = false,
Logger logger, Logger logger,
Iterable<AsyncImporter> importers, Iterable<AsyncImporter> importers,
SyncPackageResolver packageResolver, PackageConfig packageConfig,
Iterable<String> loadPaths, Iterable<String> loadPaths,
Iterable<AsyncCallable> functions, Iterable<AsyncCallable> functions,
OutputStyle style, OutputStyle style,
@ -223,9 +219,7 @@ Future<String> compileAsync(String path,
var result = await c.compileAsync(path, var result = await c.compileAsync(path,
logger: logger, logger: logger,
importCache: AsyncImportCache(importers, importCache: AsyncImportCache(importers,
logger: logger, logger: logger, loadPaths: loadPaths, packageConfig: packageConfig),
loadPaths: loadPaths,
packageResolver: packageResolver),
functions: functions, functions: functions,
style: style, style: style,
sourceMap: sourceMap != null); sourceMap: sourceMap != null);
@ -243,7 +237,7 @@ Future<String> compileStringAsync(String source,
bool color = false, bool color = false,
Logger logger, Logger logger,
Iterable<AsyncImporter> importers, Iterable<AsyncImporter> importers,
SyncPackageResolver packageResolver, PackageConfig packageConfig,
Iterable<String> loadPaths, Iterable<String> loadPaths,
Iterable<AsyncCallable> functions, Iterable<AsyncCallable> functions,
OutputStyle style, OutputStyle style,
@ -257,9 +251,7 @@ Future<String> compileStringAsync(String source,
syntax: syntax ?? (indented ? Syntax.sass : Syntax.scss), syntax: syntax ?? (indented ? Syntax.sass : Syntax.scss),
logger: logger, logger: logger,
importCache: AsyncImportCache(importers, importCache: AsyncImportCache(importers,
logger: logger, logger: logger, packageConfig: packageConfig, loadPaths: loadPaths),
packageResolver: packageResolver,
loadPaths: loadPaths),
functions: functions, functions: functions,
style: style, style: style,
importer: importer, importer: importer,

View File

@ -15,7 +15,6 @@ import 'importer.dart';
import 'importer/node.dart'; import 'importer/node.dart';
import 'io.dart'; import 'io.dart';
import 'logger.dart'; import 'logger.dart';
import 'sync_package_resolver.dart';
import 'syntax.dart'; import 'syntax.dart';
import 'utils.dart'; import 'utils.dart';
import 'visitor/async_evaluate.dart'; import 'visitor/async_evaluate.dart';
@ -77,7 +76,6 @@ Future<CompileResult> compileStringAsync(String source,
NodeImporter nodeImporter, NodeImporter nodeImporter,
Iterable<AsyncImporter> importers, Iterable<AsyncImporter> importers,
Iterable<String> loadPaths, Iterable<String> loadPaths,
SyncPackageResolver packageResolver,
AsyncImporter importer, AsyncImporter importer,
Iterable<AsyncCallable> functions, Iterable<AsyncCallable> functions,
OutputStyle style, OutputStyle style,

View File

@ -3,6 +3,7 @@
// https://opensource.org/licenses/MIT. // https://opensource.org/licenses/MIT.
import 'package:collection/collection.dart'; import 'package:collection/collection.dart';
import 'package:package_config/package_config_types.dart';
import 'package:path/path.dart' as p; import 'package:path/path.dart' as p;
import 'package:tuple/tuple.dart'; import 'package:tuple/tuple.dart';
@ -11,7 +12,6 @@ import 'importer.dart';
import 'importer/utils.dart'; import 'importer/utils.dart';
import 'io.dart'; import 'io.dart';
import 'logger.dart'; import 'logger.dart';
import 'sync_package_resolver.dart';
import 'utils.dart'; // ignore: unused_import import 'utils.dart'; // ignore: unused_import
/// An in-memory cache of parsed stylesheets that have been imported by Sass. /// An in-memory cache of parsed stylesheets that have been imported by Sass.
@ -52,16 +52,14 @@ class AsyncImportCache {
/// * Each load path specified in the `SASS_PATH` environment variable, which /// * Each load path specified in the `SASS_PATH` environment variable, which
/// should be semicolon-separated on Windows and colon-separated elsewhere. /// should be semicolon-separated on Windows and colon-separated elsewhere.
/// ///
/// * `package:` resolution using [packageResolver], which is a /// * `package:` resolution using [packageConfig], which is a
/// [`SyncPackageResolver`][] from the `package_resolver` package. Note that /// [`PackageConfig`][] from the `package_config` package. Note that
/// this is a shorthand for adding a [PackageImporter] to [importers]. /// this is a shorthand for adding a [PackageImporter] to [importers].
/// ///
/// [`SyncPackageResolver`]: https://www.dartdocs.org/documentation/package_resolver/latest/package_resolver/SyncPackageResolver-class.html /// [`PackageConfig`]: https://pub.dev/documentation/package_config/latest/package_config.package_config/PackageConfig-class.html
AsyncImportCache(Iterable<AsyncImporter> importers, AsyncImportCache(Iterable<AsyncImporter> importers,
{Iterable<String> loadPaths, {Iterable<String> loadPaths, PackageConfig packageConfig, Logger logger})
SyncPackageResolver packageResolver, : _importers = _toImporters(importers, loadPaths, packageConfig),
Logger logger})
: _importers = _toImporters(importers, loadPaths, packageResolver),
_logger = logger ?? const Logger.stderr(), _logger = logger ?? const Logger.stderr(),
_canonicalizeCache = {}, _canonicalizeCache = {},
_importCache = {}, _importCache = {},
@ -75,10 +73,10 @@ class AsyncImportCache {
_importCache = {}, _importCache = {},
_resultsCache = {}; _resultsCache = {};
/// Converts the user's [importers], [loadPaths], and [packageResolver] /// Converts the user's [importers], [loadPaths], and [packageConfig]
/// options into a single list of importers. /// options into a single list of importers.
static List<AsyncImporter> _toImporters(Iterable<AsyncImporter> importers, static List<AsyncImporter> _toImporters(Iterable<AsyncImporter> importers,
Iterable<String> loadPaths, SyncPackageResolver packageResolver) { Iterable<String> loadPaths, PackageConfig packageConfig) {
var sassPath = getEnvironmentVariable('SASS_PATH'); var sassPath = getEnvironmentVariable('SASS_PATH');
return [ return [
...?importers, ...?importers,
@ -87,7 +85,7 @@ class AsyncImportCache {
if (sassPath != null) if (sassPath != null)
for (var path in sassPath.split(isWindows ? ';' : ':')) for (var path in sassPath.split(isWindows ? ';' : ':'))
FilesystemImporter(path), FilesystemImporter(path),
if (packageResolver != null) PackageImporter(packageResolver) if (packageConfig != null) PackageImporter(packageConfig)
]; ];
} }

View File

@ -5,7 +5,7 @@
// DO NOT EDIT. This file was generated from async_compile.dart. // DO NOT EDIT. This file was generated from async_compile.dart.
// See tool/grind/synchronize.dart for details. // See tool/grind/synchronize.dart for details.
// //
// Checksum: b2cd6037efa37e300daa45ebed20cb4b61526161 // Checksum: ef27d750f1d5305373fe9e712cf99697a21e0689
// //
// ignore_for_file: unused_import // ignore_for_file: unused_import
@ -25,7 +25,6 @@ import 'importer.dart';
import 'importer/node.dart'; import 'importer/node.dart';
import 'io.dart'; import 'io.dart';
import 'logger.dart'; import 'logger.dart';
import 'sync_package_resolver.dart';
import 'syntax.dart'; import 'syntax.dart';
import 'utils.dart'; import 'utils.dart';
import 'visitor/evaluate.dart'; import 'visitor/evaluate.dart';
@ -87,7 +86,6 @@ CompileResult compileString(String source,
NodeImporter nodeImporter, NodeImporter nodeImporter,
Iterable<Importer> importers, Iterable<Importer> importers,
Iterable<String> loadPaths, Iterable<String> loadPaths,
SyncPackageResolver packageResolver,
Importer importer, Importer importer,
Iterable<Callable> functions, Iterable<Callable> functions,
OutputStyle style, OutputStyle style,

View File

@ -5,11 +5,12 @@
// DO NOT EDIT. This file was generated from async_import_cache.dart. // DO NOT EDIT. This file was generated from async_import_cache.dart.
// See tool/grind/synchronize.dart for details. // See tool/grind/synchronize.dart for details.
// //
// Checksum: 6ac1ee07d6b46134f1616d82782180f1cc3b6d81 // Checksum: 31432610e32afefcc7adcda592b811ec50e9b47f
// //
// ignore_for_file: unused_import // ignore_for_file: unused_import
import 'package:collection/collection.dart'; import 'package:collection/collection.dart';
import 'package:package_config/package_config_types.dart';
import 'package:path/path.dart' as p; import 'package:path/path.dart' as p;
import 'package:tuple/tuple.dart'; import 'package:tuple/tuple.dart';
@ -18,7 +19,6 @@ import 'importer.dart';
import 'importer/utils.dart'; import 'importer/utils.dart';
import 'io.dart'; import 'io.dart';
import 'logger.dart'; import 'logger.dart';
import 'sync_package_resolver.dart';
import 'utils.dart'; // ignore: unused_import import 'utils.dart'; // ignore: unused_import
/// An in-memory cache of parsed stylesheets that have been imported by Sass. /// An in-memory cache of parsed stylesheets that have been imported by Sass.
@ -58,16 +58,14 @@ class ImportCache {
/// * Each load path specified in the `SASS_PATH` environment variable, which /// * Each load path specified in the `SASS_PATH` environment variable, which
/// should be semicolon-separated on Windows and colon-separated elsewhere. /// should be semicolon-separated on Windows and colon-separated elsewhere.
/// ///
/// * `package:` resolution using [packageResolver], which is a /// * `package:` resolution using [packageConfig], which is a
/// [`SyncPackageResolver`][] from the `package_resolver` package. Note that /// [`PackageConfig`][] from the `package_config` package. Note that
/// this is a shorthand for adding a [PackageImporter] to [importers]. /// this is a shorthand for adding a [PackageImporter] to [importers].
/// ///
/// [`SyncPackageResolver`]: https://www.dartdocs.org/documentation/package_resolver/latest/package_resolver/SyncPackageResolver-class.html /// [`PackageConfig`]: https://pub.dev/documentation/package_config/latest/package_config.package_config/PackageConfig-class.html
ImportCache(Iterable<Importer> importers, ImportCache(Iterable<Importer> importers,
{Iterable<String> loadPaths, {Iterable<String> loadPaths, PackageConfig packageConfig, Logger logger})
SyncPackageResolver packageResolver, : _importers = _toImporters(importers, loadPaths, packageConfig),
Logger logger})
: _importers = _toImporters(importers, loadPaths, packageResolver),
_logger = logger ?? const Logger.stderr(), _logger = logger ?? const Logger.stderr(),
_canonicalizeCache = {}, _canonicalizeCache = {},
_importCache = {}, _importCache = {},
@ -81,10 +79,10 @@ class ImportCache {
_importCache = {}, _importCache = {},
_resultsCache = {}; _resultsCache = {};
/// Converts the user's [importers], [loadPaths], and [packageResolver] /// Converts the user's [importers], [loadPaths], and [packageConfig]
/// options into a single list of importers. /// options into a single list of importers.
static List<Importer> _toImporters(Iterable<Importer> importers, static List<Importer> _toImporters(Iterable<Importer> importers,
Iterable<String> loadPaths, SyncPackageResolver packageResolver) { Iterable<String> loadPaths, PackageConfig packageConfig) {
var sassPath = getEnvironmentVariable('SASS_PATH'); var sassPath = getEnvironmentVariable('SASS_PATH');
return [ return [
...?importers, ...?importers,
@ -93,7 +91,7 @@ class ImportCache {
if (sassPath != null) if (sassPath != null)
for (var path in sassPath.split(isWindows ? ';' : ':')) for (var path in sassPath.split(isWindows ? ';' : ':'))
FilesystemImporter(path), FilesystemImporter(path),
if (packageResolver != null) PackageImporter(packageResolver) if (packageConfig != null) PackageImporter(packageConfig)
]; ];
} }

View File

@ -3,9 +3,9 @@
// https://opensource.org/licenses/MIT. // https://opensource.org/licenses/MIT.
import 'package:meta/meta.dart'; import 'package:meta/meta.dart';
import 'package:package_config/package_config_types.dart';
import '../importer.dart'; import '../importer.dart';
import '../sync_package_resolver.dart';
/// A filesystem importer to use when resolving the results of `package:` URLs. /// A filesystem importer to use when resolving the results of `package:` URLs.
/// ///
@ -17,24 +17,24 @@ final _filesystemImporter = FilesystemImporter('.');
@sealed @sealed
class PackageImporter extends Importer { class PackageImporter extends Importer {
/// The resolver that converts `package:` imports to `file:`. /// The resolver that converts `package:` imports to `file:`.
final SyncPackageResolver _packageResolver; final PackageConfig _packageConfig;
/// Creates an importer that loads stylesheets from `package:` URLs according /// Creates an importer that loads stylesheets from `package:` URLs according
/// to [packageResolver], which is a [SyncPackageResolver][] from the /// to [packageConfig], which is a [PackageConfig][] from the `package_config`
/// `package_resolver` package. /// package.
/// ///
/// [SyncPackageResolver]: https://www.dartdocs.org/documentation/package_resolver/latest/package_resolver/SyncPackageResolver-class.html /// [`PackageConfig`]: https://pub.dev/documentation/package_config/latest/package_config.package_config/PackageConfig-class.html
PackageImporter(this._packageResolver); PackageImporter(this._packageConfig);
Uri canonicalize(Uri url) { Uri canonicalize(Uri url) {
if (url.scheme == 'file') return _filesystemImporter.canonicalize(url); if (url.scheme == 'file') return _filesystemImporter.canonicalize(url);
if (url.scheme != 'package') return null; if (url.scheme != 'package') return null;
var resolved = _packageResolver.resolveUri(url); var resolved = _packageConfig.resolve(url);
if (resolved == null) throw "Unknown package."; if (resolved == null) throw "Unknown package.";
if (resolved.scheme.isNotEmpty && resolved.scheme != 'file') { if (resolved.scheme.isNotEmpty && resolved.scheme != 'file') {
throw "Unsupported URL ${resolved}."; throw "Unsupported URL $resolved.";
} }
return _filesystemImporter.canonicalize(resolved); return _filesystemImporter.canonicalize(resolved);

View File

@ -1,2 +0,0 @@
export 'package:package_resolver/package_resolver.dart'
if (dart.library.js) 'sync_package_resolver/node.dart';

View File

@ -1,15 +0,0 @@
// Copyright (c) 2016, the Dart project authors. Please see the AUTHORS file
// for details. All rights reserved. Use of this source code is governed by a
// BSD-style license that can be found in the LICENSE file.
class SyncPackageResolver {
static final _error =
UnsupportedError('SyncPackageResolver is not supported in JS.');
static Future<SyncPackageResolver> get current => throw _error;
Uri resolveUri(Object packageUri) => throw _error;
factory SyncPackageResolver.config(Map<String, Uri> configMap) =>
throw _error;
}

View File

@ -12,37 +12,38 @@ environment:
sdk: '>=2.6.0 <3.0.0' sdk: '>=2.6.0 <3.0.0'
dependencies: dependencies:
args: ">=1.4.0 <3.0.0" args: ^2.0.0
async: ">=1.10.0 <3.0.0" async: ^2.5.0
charcode: "^1.1.0" charcode: ^1.2.0
cli_repl: ">=0.1.3 <0.3.0" cli_repl: ^0.2.1-nullsafety
collection: "^1.8.0" collection: ^1.15.0
meta: "^1.1.7" meta: ^1.3.0
node_interop: "^1.1.0" node_interop: ^2.0.0
js: "^0.6.0" js: ^0.6.3
package_resolver: "^1.0.0" path: ^1.8.0
path: "^1.6.0" source_maps: ^0.10.10
source_maps: "^0.10.5" source_span: ^1.8.1
source_span: "^1.6.0" stack_trace: ^1.10.0
stack_trace: ">=0.9.0 <2.0.0" stream_transform: ^2.0.0
stream_transform: ">=0.0.20 <3.0.0" string_scanner: ^1.1.0
string_scanner: ">=0.1.5 <2.0.0" term_glyph: ^1.2.0
term_glyph: "^1.0.0" tuple: ^2.0.0-nullsafety.0
tuple: "^1.0.0" watcher: ^1.0.0
watcher: ">=0.9.6 <2.0.0"
publish_to: none
dev_dependencies: dev_dependencies:
archive: ">=1.0.0 <3.0.0" archive: ^3.1.2
analyzer: "^0.40.0" analyzer: ^1.1.0
cli_pkg: "^1.1.0" cli_pkg: ^1.3.0
crypto: ">=0.9.2 <3.0.0" crypto: ^3.0.0
dart_style: "^1.2.0" dart_style: ^2.0.0
grinder: "^0.8.0" grinder: ^0.9.0-nullsafety.0
node_preamble: "^1.1.0" node_preamble: ^2.0.0
pedantic: "^1.0.0" pedantic: ^1.11.0
pub_semver: "^1.0.0" pub_semver: ^2.0.0
stream_channel: ">=1.0.0 <3.0.0" stream_channel: ^2.1.0
test_descriptor: "^1.1.0" test_descriptor: ^2.0.0
test_process: "^1.0.0-rc.1" test_process: ^2.0.0
test: ">=0.12.42 <2.0.0" test: ^1.16.7
yaml: "^2.0.0" yaml: ^3.1.0

View File

@ -4,6 +4,8 @@
@TestOn('vm') @TestOn('vm')
import 'dart:convert';
import 'package:cli_pkg/testing.dart' as pkg; import 'package:cli_pkg/testing.dart' as pkg;
import 'package:test/test.dart'; import 'package:test/test.dart';
import 'package:test_descriptor/test_descriptor.dart' as d; import 'package:test_descriptor/test_descriptor.dart' as d;
@ -30,4 +32,4 @@ void ensureSnapshotUpToDate() => pkg.ensureExecutableUpToDate("sass");
Future<TestProcess> runSass(Iterable<String> arguments, Future<TestProcess> runSass(Iterable<String> arguments,
{Map<String, String> environment}) => {Map<String, String> environment}) =>
pkg.start("sass", arguments, pkg.start("sass", arguments,
environment: environment, workingDirectory: d.sandbox); environment: environment, workingDirectory: d.sandbox, encoding: utf8);

View File

@ -5,6 +5,8 @@
@TestOn('vm') @TestOn('vm')
@Tags(['node']) @Tags(['node'])
import 'dart:convert';
import 'package:cli_pkg/testing.dart' as pkg; import 'package:cli_pkg/testing.dart' as pkg;
import 'package:test_process/test_process.dart'; import 'package:test_process/test_process.dart';
import 'package:test_descriptor/test_descriptor.dart' as d; import 'package:test_descriptor/test_descriptor.dart' as d;
@ -31,4 +33,7 @@ void main() {
Future<TestProcess> runSass(Iterable<String> arguments, Future<TestProcess> runSass(Iterable<String> arguments,
{Map<String, String> environment}) => {Map<String, String> environment}) =>
pkg.start("sass", arguments, pkg.start("sass", arguments,
environment: environment, workingDirectory: d.sandbox, node: true); environment: environment,
workingDirectory: d.sandbox,
encoding: utf8,
node: true);

View File

@ -4,7 +4,7 @@
@TestOn('vm') @TestOn('vm')
import 'package:package_resolver/package_resolver.dart'; import 'package:package_config/package_config.dart';
import 'package:path/path.dart' as p; import 'package:path/path.dart' as p;
import 'package:test/test.dart'; import 'package:test/test.dart';
import 'package:test_descriptor/test_descriptor.dart' as d; import 'package:test_descriptor/test_descriptor.dart' as d;
@ -93,10 +93,10 @@ void main() {
await d await d
.file("test.scss", '@import "package:fake_package/test";') .file("test.scss", '@import "package:fake_package/test";')
.create(); .create();
var resolver = SyncPackageResolver.config( var config =
{"fake_package": p.toUri(d.path('subdir'))}); PackageConfig([Package('fake_package', p.toUri(d.path('subdir/')))]);
var css = compile(d.path("test.scss"), packageResolver: resolver); var css = compile(d.path("test.scss"), packageConfig: config);
expect(css, equals("a {\n b: 3;\n}")); expect(css, equals("a {\n b: 3;\n}"));
}); });
@ -109,10 +109,10 @@ void main() {
await d await d
.file("test.scss", '@import "package:fake_package/test";') .file("test.scss", '@import "package:fake_package/test";')
.create(); .create();
var resolver = SyncPackageResolver.config( var config =
{"fake_package": p.toUri(d.path('subdir'))}); PackageConfig([Package('fake_package', p.toUri(d.path('subdir/')))]);
var css = compile(d.path("test.scss"), packageResolver: resolver); var css = compile(d.path("test.scss"), packageConfig: config);
expect(css, equals("a {\n b: 3;\n}")); expect(css, equals("a {\n b: 3;\n}"));
}); });
@ -120,9 +120,9 @@ void main() {
await d await d
.file("test.scss", '@import "package:fake_package/test_aux";') .file("test.scss", '@import "package:fake_package/test_aux";')
.create(); .create();
var resolver = SyncPackageResolver.config({});
expect(() => compile(d.path("test.scss"), packageResolver: resolver), expect(
() => compile(d.path("test.scss"), packageConfig: PackageConfig([])),
throwsA(const TypeMatcher<SassRuntimeException>())); throwsA(const TypeMatcher<SassRuntimeException>()));
}); });
}); });
@ -166,9 +166,9 @@ void main() {
expect(css, equals("a {\n b: from-importer;\n}")); expect(css, equals("a {\n b: from-importer;\n}"));
}); });
test("importers take precedence over packageResolver", () async { test("importers take precedence over packageConfig", () async {
await d.dir("package", await d.dir("package",
[d.file("other.scss", "a {b: from-package-resolver}")]).create(); [d.file("other.scss", "a {b: from-package-config}")]).create();
await d.dir( await d.dir(
"importer", [d.file("other.scss", "a {b: from-importer}")]).create(); "importer", [d.file("other.scss", "a {b: from-importer}")]).create();
await d await d
@ -177,11 +177,11 @@ void main() {
var css = compile(d.path("test.scss"), var css = compile(d.path("test.scss"),
importers: [ importers: [
PackageImporter(SyncPackageResolver.config( PackageImporter(PackageConfig(
{"fake_package": p.toUri(d.path('importer'))})) [Package('fake_package', p.toUri(d.path('importer/')))]))
], ],
packageResolver: SyncPackageResolver.config( packageConfig: PackageConfig(
{"fake_package": p.toUri(d.path('package'))})); [Package('fake_package', p.toUri(d.path('package/')))]));
expect(css, equals("a {\n b: from-importer;\n}")); expect(css, equals("a {\n b: from-importer;\n}"));
}); });
}); });

View File

@ -44,7 +44,7 @@ void main() {
var changelogVersion = firstLine.substring(3); var changelogVersion = firstLine.substring(3);
var pubspec = loadYaml(File("pubspec.yaml").readAsStringSync(), var pubspec = loadYaml(File("pubspec.yaml").readAsStringSync(),
sourceUrl: "pubspec.yaml") as Map<Object, Object>; sourceUrl: Uri(path: "pubspec.yaml")) as Map<dynamic, dynamic>;
expect(pubspec, containsPair("version", isA<String>())); expect(pubspec, containsPair("version", isA<String>()));
var pubspecVersion = pubspec["version"] as String; var pubspecVersion = pubspec["version"] as String;