Skip to content

Commit b5fd140

Browse files
authored
Fix relative imports through relative load paths in the Node API (#315)
Closes #314
1 parent ecbf1ae commit b5fd140

File tree

4 files changed

+25
-2
lines changed

4 files changed

+25
-2
lines changed

CHANGELOG.md

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,10 @@
1+
## 1.3.1
2+
3+
### Node API
4+
5+
* Fix loading imports relative to stylesheets that were themselves imported
6+
though relative include paths.
7+
18
## 1.3.0
29

310
### Command-Line Interface

lib/src/importer/node/implementation.dart

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -119,7 +119,7 @@ class NodeImporter {
119119

120120
// 3: Filesystem imports relative to [_includePaths].
121121
for (var includePath in _includePaths) {
122-
var result = _tryPath(p.join(includePath, path));
122+
var result = _tryPath(p.absolute(p.join(includePath, path)));
123123
if (result != null) return result;
124124
}
125125

pubspec.yaml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
name: sass
2-
version: 1.3.0
2+
version: 1.3.1
33
description: A Sass implementation in Dart.
44
author: Dart Team <[email protected]>
55
homepage: https://github.com/sass/dart-sass

test/node_api_test.dart

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -96,6 +96,22 @@ void main() {
9696
equalsIgnoringWhitespace('a { b: c; }'));
9797
});
9898

99+
// Regression test for #314
100+
test(
101+
"a file imported through a relative load path supports relative "
102+
"imports", () async {
103+
var subDir = p.join(sandbox, 'sub');
104+
await createDirectory(subDir);
105+
await writeTextFile(p.join(subDir, '_test.scss'), '@import "other"');
106+
107+
await writeTextFile(p.join(subDir, '_other.scss'), 'x {y: z}');
108+
109+
expect(
110+
renderSync(new RenderOptions(
111+
data: "@import 'sub/test'", includePaths: [p.relative(sandbox)])),
112+
equalsIgnoringWhitespace('x { y: z; }'));
113+
});
114+
99115
test("can render the indented syntax", () {
100116
expect(
101117
renderSync(

0 commit comments

Comments
 (0)