Skip to content

Commit 6781fbb

Browse files
authored
Merge pull request #209 from dahlia/add_cwd_to_include_paths
Always include cwd in import paths
2 parents 6e2df5d + a320d5c commit 6781fbb

File tree

2 files changed

+17
-10
lines changed

2 files changed

+17
-10
lines changed

sass.py

Lines changed: 7 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -283,7 +283,7 @@ def compile(**kwargs):
283283
:type source_comments: :class:`bool`
284284
:param include_paths: an optional list of paths to find ``@import``\ ed
285285
SASS/CSS source files
286-
:type include_paths: :class:`collections.Sequence`, :class:`str`
286+
:type include_paths: :class:`collections.Sequence`
287287
:param precision: optional precision for numbers. :const:`5` by default.
288288
:type precision: :class:`int`
289289
:param custom_functions: optional mapping of custom functions.
@@ -323,7 +323,7 @@ def compile(**kwargs):
323323
:type source_map_filename: :class:`str`
324324
:param include_paths: an optional list of paths to find ``@import``\ ed
325325
SASS/CSS source files
326-
:type include_paths: :class:`collections.Sequence`, :class:`str`
326+
:type include_paths: :class:`collections.Sequence`
327327
:param precision: optional precision for numbers. :const:`5` by default.
328328
:type precision: :class:`int`
329329
:param custom_functions: optional mapping of custom functions.
@@ -365,7 +365,7 @@ def compile(**kwargs):
365365
:type source_comments: :class:`bool`
366366
:param include_paths: an optional list of paths to find ``@import``\ ed
367367
SASS/CSS source files
368-
:type include_paths: :class:`collections.Sequence`, :class:`str`
368+
:type include_paths: :class:`collections.Sequence`
369369
:param precision: optional precision for numbers. :const:`5` by default.
370370
:type precision: :class:`int`
371371
:param custom_functions: optional mapping of custom functions.
@@ -556,13 +556,10 @@ def _get_file_arg(key):
556556
source_map_filename = _get_file_arg('source_map_filename')
557557
output_filename_hint = _get_file_arg('output_filename_hint')
558558

559-
include_paths = kwargs.pop('include_paths', b'') or b''
560-
if isinstance(include_paths, collections.Sequence):
561-
include_paths = os.pathsep.join(include_paths)
562-
elif not isinstance(include_paths, string_types):
563-
raise TypeError('include_paths must be a sequence of strings, or '
564-
'a colon-separated (or semicolon-separated if '
565-
'Windows) string, not ' + repr(include_paths))
559+
# #208: cwd is always included in include paths
560+
include_paths = (os.getcwd(),)
561+
include_paths += tuple(kwargs.pop('include_paths', ()) or ())
562+
include_paths = os.pathsep.join(include_paths)
566563
if isinstance(include_paths, text_type):
567564
include_paths = include_paths.encode(fs_encoding)
568565

sasstests.py

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1388,3 +1388,13 @@ def test_sassc_sourcemap(tmpdir):
13881388
'file': 'a.scss.css',
13891389
'mappings': 'AAAA,AAAA,EAAE,CAAC;EAAE,SAAS,EAAE,IAAS,GAAI',
13901390
}
1391+
1392+
1393+
def test_imports_from_cwd(tmpdir):
1394+
scss_dir = tmpdir.join('scss').ensure_dir()
1395+
scss_dir.join('_variables.scss').ensure()
1396+
main_scss = scss_dir.join('main.scss')
1397+
main_scss.write("@import 'scss/variables';")
1398+
with tmpdir.as_cwd():
1399+
out = sass.compile(filename=main_scss.strpath)
1400+
assert out == ''

0 commit comments

Comments
 (0)