diff --git a/sasstests.py b/sasstests.py index f5210f94..6c8b3354 100644 --- a/sasstests.py +++ b/sasstests.py @@ -66,6 +66,11 @@ font: '나눔고딕', sans-serif; } ''' +E_EXPECTED_CSS = '''\ +a { + color: red; } +''' + SUBDIR_RECUR_EXPECTED_CSS = '''\ body p { color: blue; } @@ -187,6 +192,8 @@ def test_compile_filename(self): self.assertEqual(D_EXPECTED_CSS, actual) else: self.assertEqual(D_EXPECTED_CSS.decode('utf-8'), actual) + actual = sass.compile(filename='test/e.scss') + assert actual == E_EXPECTED_CSS self.assertRaises(IOError, sass.compile, filename='test/not-exist.sass') self.assertRaises(TypeError, sass.compile, filename=1234) @@ -234,7 +241,7 @@ def test_builder_build_directory(self): css_path = os.path.join(temp_path, 'css') shutil.copytree('test', sass_path) result_files = build_directory(sass_path, css_path) - assert len(result_files) == 5 + assert len(result_files) == 6 assert result_files['a.scss'] == 'a.scss.css' with open(os.path.join(css_path, 'a.scss.css'), **utf8_if_py3) as f: css = f.read() @@ -251,6 +258,10 @@ def test_builder_build_directory(self): with open(os.path.join(css_path, 'd.scss.css'), **utf8_if_py3) as f: css = f.read() self.assertEqual(D_EXPECTED_CSS, css) + assert result_files['e.scss'] == 'e.scss.css' + with open(os.path.join(css_path, 'e.scss.css'), **utf8_if_py3) as f: + css = f.read() + assert css == E_EXPECTED_CSS assert (result_files[os.path.join('subdir', 'recur.scss')] == os.path.join('subdir', 'recur.scss.css')) with open(os.path.join(css_path, 'subdir', 'recur.scss.css'), diff --git a/sassutils/builder.py b/sassutils/builder.py index 53d4554e..0ec45864 100644 --- a/sassutils/builder.py +++ b/sassutils/builder.py @@ -46,6 +46,9 @@ def build_directory(sass_path, css_path, _root_sass=None, _root_css=None): for name in os.listdir(sass_path): sass_fullname = os.path.join(sass_path, name) if SUFFIX_PATTERN.search(name) and os.path.isfile(sass_fullname): + if name[0] == '_': + # Do not compile if it's partial + continue css_fullname = os.path.join(css_path, name) + '.css' css = compile(filename=sass_fullname, include_paths=[_root_sass]) with io.open(css_fullname, 'w', encoding='utf-8') as css_file: diff --git a/test/_f.scss b/test/_f.scss new file mode 100644 index 00000000..d01cad8d --- /dev/null +++ b/test/_f.scss @@ -0,0 +1 @@ +$test-variable : true !default; diff --git a/test/e.scss b/test/e.scss new file mode 100644 index 00000000..005d3453 --- /dev/null +++ b/test/e.scss @@ -0,0 +1,2 @@ +@import "f"; +@import "subdir/sub"; diff --git a/test/subdir/_sub.scss b/test/subdir/_sub.scss new file mode 100644 index 00000000..4ac2d132 --- /dev/null +++ b/test/subdir/_sub.scss @@ -0,0 +1,5 @@ +@if $test-variable == true { + a { + color: red; + } +}