Skip to content

Commit e63b8e1

Browse files
john681611nex3
authored andcommitted
Add support for _index files (#220)
See sass/sass#690
1 parent b7b4580 commit e63b8e1

File tree

4 files changed

+19
-5
lines changed

4 files changed

+19
-5
lines changed

Diff for: AUTHORS

+1
Original file line numberDiff line numberDiff line change
@@ -4,3 +4,4 @@
44
# Name/Organization <email address>
55

66
Google Inc.
7+
Marks and Spencer Plc. John Harvey [email protected]

Diff for: CHANGELOG.md

+5
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,8 @@
1+
## 1.0.0-beta.6
2+
3+
* Add support for importing an `_index.scss` or `_index.sass` file when
4+
importing a directory.
5+
16
## 1.0.0-beta.5.3
27

38
* Support hard tabs in the indented syntax.

Diff for: lib/src/importer/utils.dart

+12-4
Original file line numberDiff line numberDiff line change
@@ -7,13 +7,14 @@ import '../util/path.dart';
77

88
/// Resolves an imported path using the same logic as the filesystem importer.
99
///
10-
/// This tries to fill in extensions and partial prefixes. If no file can be
10+
/// This tries to fill in extensions and partial prefixes and check if a directory default. If no file can be
1111
/// found, it returns `null`.
1212
String resolveImportPath(String path) {
1313
var extension = p.extension(path);
14-
return extension == '.sass' || extension == '.scss'
15-
? _tryPath(path)
16-
: _tryPathWithExtensions(path);
14+
if (extension == '.sass' || extension == '.scss') return _tryPath(path);
15+
16+
var file = _tryPathWithExtensions(path);
17+
return file != null ? file : _tryPathAsDirectory(path);
1718
}
1819

1920
/// Like [_tryPath], but checks both `.sass` and `.scss` extensions.
@@ -30,3 +31,10 @@ String _tryPath(String path) {
3031
if (fileExists(path)) return path;
3132
return null;
3233
}
34+
35+
/// Returns the resolved index file for [path] if [path] is a directory and the
36+
/// index file exists.
37+
///
38+
/// Otherwise, returns `null`.
39+
String _tryPathAsDirectory(String path) =>
40+
dirExists(path) ? _tryPathWithExtensions(p.join(path, 'index')) : null;

Diff for: pubspec.yaml

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
name: sass
2-
version: 1.0.0-beta.5.3
2+
version: 1.0.0-dev
33
description: A Sass implementation in Dart.
44
author: Dart Team <[email protected]>
55
homepage: https://github.com/sass/dart-sass

0 commit comments

Comments
 (0)