Skip to content

Commit

Permalink
Always include cwd in import paths
Browse files Browse the repository at this point in the history
  • Loading branch information
asottile committed Jun 14, 2017
1 parent 6e2df5d commit a320d5c
Show file tree
Hide file tree
Showing 2 changed files with 17 additions and 10 deletions.
17 changes: 7 additions & 10 deletions sass.py
Expand Up @@ -283,7 +283,7 @@ def compile(**kwargs):
:type source_comments: :class:`bool`
:param include_paths: an optional list of paths to find ``@import``\ ed
SASS/CSS source files
:type include_paths: :class:`collections.Sequence`, :class:`str`
:type include_paths: :class:`collections.Sequence`
:param precision: optional precision for numbers. :const:`5` by default.
:type precision: :class:`int`
:param custom_functions: optional mapping of custom functions.
Expand Down Expand Up @@ -323,7 +323,7 @@ def compile(**kwargs):
:type source_map_filename: :class:`str`
:param include_paths: an optional list of paths to find ``@import``\ ed
SASS/CSS source files
:type include_paths: :class:`collections.Sequence`, :class:`str`
:type include_paths: :class:`collections.Sequence`
:param precision: optional precision for numbers. :const:`5` by default.
:type precision: :class:`int`
:param custom_functions: optional mapping of custom functions.
Expand Down Expand Up @@ -365,7 +365,7 @@ def compile(**kwargs):
:type source_comments: :class:`bool`
:param include_paths: an optional list of paths to find ``@import``\ ed
SASS/CSS source files
:type include_paths: :class:`collections.Sequence`, :class:`str`
:type include_paths: :class:`collections.Sequence`
:param precision: optional precision for numbers. :const:`5` by default.
:type precision: :class:`int`
:param custom_functions: optional mapping of custom functions.
Expand Down Expand Up @@ -556,13 +556,10 @@ def _get_file_arg(key):
source_map_filename = _get_file_arg('source_map_filename')
output_filename_hint = _get_file_arg('output_filename_hint')

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

Expand Down
10 changes: 10 additions & 0 deletions sasstests.py
Expand Up @@ -1388,3 +1388,13 @@ def test_sassc_sourcemap(tmpdir):
'file': 'a.scss.css',
'mappings': 'AAAA,AAAA,EAAE,CAAC;EAAE,SAAS,EAAE,IAAS,GAAI',
}


def test_imports_from_cwd(tmpdir):
scss_dir = tmpdir.join('scss').ensure_dir()
scss_dir.join('_variables.scss').ensure()
main_scss = scss_dir.join('main.scss')
main_scss.write("@import 'scss/variables';")
with tmpdir.as_cwd():
out = sass.compile(filename=main_scss.strpath)
assert out == ''

0 comments on commit a320d5c

Please sign in to comment.