Skip to content

Commit

Permalink
Merge pull request #1426 from sass/windows-path-importer
Browse files Browse the repository at this point in the history
Fix a crash in the Node importer
  • Loading branch information
nex3 authored Aug 10, 2021
2 parents e4f38a7 + 682cbbf commit 5d8e622
Show file tree
Hide file tree
Showing 7 changed files with 33 additions and 7 deletions.
7 changes: 7 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,10 @@
## 1.37.6

### JS API

* Don't crash when a Windows path is returned by a custom Node importer at the
same time as file contents.

## 1.37.5

* No user-visible changes.
Expand Down
2 changes: 1 addition & 1 deletion lib/src/importer/node/implementation.dart
Original file line number Diff line number Diff line change
Expand Up @@ -186,7 +186,7 @@ class NodeImporter {
if (file == null) {
return Tuple2(contents ?? '', url);
} else if (contents != null) {
return Tuple2(contents, file);
return Tuple2(contents, p.toUri(file).toString());
} else {
var resolved =
loadRelative(p.toUri(file).toString(), previous, forImport) ??
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 @@
## 1.0.0-beta.3

* No user-visible changes.

## 1.0.0-beta.2

* No user-visible changes.
Expand Down
4 changes: 2 additions & 2 deletions pkg/sass_api/pubspec.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -2,15 +2,15 @@ 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: 1.0.0-beta.2
version: 1.0.0-dev
description: Additional APIs for Dart Sass.
homepage: https://github.com/sass/dart-sass

environment:
sdk: '>=2.12.0 <3.0.0'

dependencies:
sass: 1.37.5
sass: 1.37.6

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.37.5
version: 1.37.6-dev
description: A Sass implementation in Dart.
homepage: https://github.com/sass/dart-sass

Expand Down
11 changes: 8 additions & 3 deletions test/double_check_test.dart
Original file line number Diff line number Diff line change
Expand Up @@ -50,13 +50,18 @@ void main() {
.convert(File("$package/CHANGELOG.md").readAsStringSync())
.first;
expect(firstLine, startsWith("## "));
var changelogVersion = firstLine.substring(3);
var changelogVersion = Version.parse(firstLine.substring(3));

var pubspec = Pubspec.parse(
File("$package/pubspec.yaml").readAsStringSync(),
sourceUrl: p.toUri("$package/pubspec.yaml"));
expect(pubspec.version!.toString(),
anyOf(equals(changelogVersion), equals("$changelogVersion-dev")));
expect(
pubspec.version!.toString(),
anyOf(
equals(changelogVersion.toString()),
changelogVersion.isPreRelease
? equals("${changelogVersion.nextPatch}-dev")
: equals("$changelogVersion-dev")));
});
});
}
Expand Down
10 changes: 10 additions & 0 deletions test/node_api/importer_test.dart
Original file line number Diff line number Diff line change
Expand Up @@ -141,6 +141,16 @@ void main() {
}))));
expect(result.stats.includedFiles, equals(['bar']));
});

// Regression test for sass/dart-sass#1410.
test("passes through an absolute file path", () {
var result = sass.renderSync(RenderOptions(
data: "@import 'foo'",
importer: allowInterop(expectAsync2((void _, void __) {
return NodeImporterResult(contents: '', file: p.absolute('bar'));
}))));
expect(result.stats.includedFiles, equals([p.absolute('bar')]));
});
});

group("with a file redirect", () {
Expand Down

0 comments on commit 5d8e622

Please sign in to comment.