Only claim "package:" URLs are unsupported on Node (#637)

Closes #630
This commit is contained in:
Natalie Weizenbaum 2019-04-04 12:17:36 -07:00 committed by GitHub
parent 9621979b71
commit 495c6f3163
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
6 changed files with 43 additions and 20 deletions

View File

@ -2,6 +2,8 @@
* Fix importing files relative to `package:`-imported files.
* Don't claim that "package:" URLs aren't supported when they actually are.
### Dart API
* Explicitly require that importers' `canonicalize()` methods be able to take

View File

@ -27,6 +27,7 @@ import '../extend/extender.dart';
import '../importer.dart';
import '../importer/node.dart';
import '../importer/utils.dart';
import '../io.dart';
import '../logger.dart';
import '../parse/keyframe_selector.dart';
import '../syntax.dart';
@ -851,7 +852,7 @@ class _EvaluateVisitor
if (tuple != null) return tuple;
}
if (url.startsWith('package:')) {
if (url.startsWith('package:') && isNode) {
// Special-case this error message, since it's tripped people up in the
// past.
throw "\"package:\" URLs aren't supported on this platform.";

View File

@ -5,7 +5,7 @@
// DO NOT EDIT. This file was generated from async_evaluate.dart.
// See tool/synchronize.dart for details.
//
// Checksum: be2d44a3dc50defd98446d806b4c21bfe54a4ba9
// Checksum: e7642c8d4c838f0afe94b882794e81b0937ba1a1
//
// ignore_for_file: unused_import
@ -36,6 +36,7 @@ import '../extend/extender.dart';
import '../importer.dart';
import '../importer/node.dart';
import '../importer/utils.dart';
import '../io.dart';
import '../logger.dart';
import '../parse/keyframe_selector.dart';
import '../syntax.dart';
@ -851,7 +852,7 @@ class _EvaluateVisitor
if (tuple != null) return tuple;
}
if (url.startsWith('package:')) {
if (url.startsWith('package:') && isNode) {
// Special-case this error message, since it's tripped people up in the
// past.
throw "\"package:\" URLs aren't supported on this platform.";

View File

@ -5,6 +5,7 @@
@TestOn('vm')
import 'package:test/test.dart';
import 'package:test_descriptor/test_descriptor.dart' as d;
import '../dart_test.dart';
import '../shared/errors.dart';
@ -12,4 +13,21 @@ import '../shared/errors.dart';
void main() {
setUpAll(ensureSnapshotUpToDate);
sharedTests(runSass);
test("for package urls", () async {
await d.file("test.scss", "@import 'package:nope/test';").create();
var sass = await runSass(["--no-unicode", "test.scss"]);
expect(
sass.stderr,
emitsInOrder([
"Error: Can't find stylesheet to import.",
" ,",
"1 | @import 'package:nope/test';",
" | ^^^^^^^^^^^^^^^^^^^",
" '",
" test.scss 1:9 root stylesheet"
]));
await sass.shouldExit(65);
});
}

View File

@ -6,6 +6,7 @@
@Tags(['node'])
import 'package:test/test.dart';
import 'package:test_descriptor/test_descriptor.dart' as d;
import '../../ensure_npm_package.dart';
import '../node_test.dart';
@ -14,4 +15,21 @@ import '../shared/errors.dart';
void main() {
setUpAll(ensureNpmPackage);
sharedTests(runSass);
test("for package urls", () async {
await d.file("test.scss", "@import 'package:nope/test';").create();
var sass = await runSass(["--no-unicode", "test.scss"]);
expect(
sass.stderr,
emitsInOrder([
"Error: \"package:\" URLs aren't supported on this platform.",
" ,",
"1 | @import 'package:nope/test';",
" | ^^^^^^^^^^^^^^^^^^^",
" '",
" test.scss 1:9 root stylesheet"
]));
await sass.shouldExit(65);
});
}

View File

@ -113,21 +113,4 @@ void sharedTests(Future<TestProcess> runSass(Iterable<String> arguments)) {
expect(sass.stderr, emitsThrough(contains("\.dart")));
await sass.shouldExit(65);
});
test("for package urls", () async {
await d.file("test.scss", "@import 'package:nope/test';").create();
var sass = await runSass(["--no-unicode", "test.scss"]);
expect(
sass.stderr,
emitsInOrder([
"Error: \"package:\" URLs aren't supported on this platform.",
" ,",
"1 | @import 'package:nope/test';",
" | ^^^^^^^^^^^^^^^^^^^",
" '",
" test.scss 1:9 root stylesheet"
]));
await sass.shouldExit(65);
});
}