Skip to content
This repository was archived by the owner on Oct 24, 2025. It is now read-only.

Commit e09f32d

Browse files
committed
Fix recursive subdirectory build bug
1 parent d562156 commit e09f32d

File tree

4 files changed

+21
-4
lines changed

4 files changed

+21
-4
lines changed

docs/changes.rst

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,10 @@ To be released.
99
- Fixed a bug that :class:`~sassutils.wsgi.SassMiddleware` yielded
1010
:class:`str` instead of :class:`bytes` on Python 3.
1111
- Fixed several Unicode-related bugs on Windows.
12+
- Fixed a bug that :func:`~sassutils.builder.build_directory()`,
13+
:class:`~sassutils.wsgi.SassMiddleware`, and
14+
:class:`~sassutils.distutils.build_sass` don't recursively build
15+
subdirectories.
1216

1317

1418
Version 0.5.0

sasstests.py

Lines changed: 12 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -66,6 +66,11 @@
6666
font: '나눔고딕', sans-serif; }
6767
'''
6868

69+
SUBDIR_RECUR_EXPECTED_CSS = '''\
70+
body p {
71+
color: blue; }
72+
'''
73+
6974
utf8_if_py3 = {'encoding': 'utf-8'} if PY3 else {}
7075

7176

@@ -229,7 +234,7 @@ def test_builder_build_directory(self):
229234
css_path = os.path.join(temp_path, 'css')
230235
shutil.copytree('test', sass_path)
231236
result_files = build_directory(sass_path, css_path)
232-
assert len(result_files) == 4
237+
assert len(result_files) == 5
233238
assert result_files['a.scss'] == 'a.scss.css'
234239
with open(os.path.join(css_path, 'a.scss.css'), **utf8_if_py3) as f:
235240
css = f.read()
@@ -246,6 +251,12 @@ def test_builder_build_directory(self):
246251
with open(os.path.join(css_path, 'd.scss.css'), **utf8_if_py3) as f:
247252
css = f.read()
248253
self.assertEqual(D_EXPECTED_CSS, css)
254+
assert (result_files[os.path.join('subdir', 'recur.scss')] ==
255+
os.path.join('subdir', 'recur.scss.css'))
256+
with open(os.path.join(css_path, 'subdir', 'recur.scss.css'),
257+
**utf8_if_py3) as f:
258+
css = f.read()
259+
self.assertEqual(SUBDIR_RECUR_EXPECTED_CSS, css)
249260
shutil.rmtree(temp_path)
250261

251262

sassutils/builder.py

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -44,10 +44,8 @@ def build_directory(sass_path, css_path, _root_sass=None, _root_css=None):
4444
if not os.path.isdir(css_path):
4545
os.mkdir(css_path)
4646
for name in os.listdir(sass_path):
47-
if not SUFFIX_PATTERN.search(name):
48-
continue
4947
sass_fullname = os.path.join(sass_path, name)
50-
if os.path.isfile(sass_fullname):
48+
if SUFFIX_PATTERN.search(name) and os.path.isfile(sass_fullname):
5149
css_fullname = os.path.join(css_path, name) + '.css'
5250
css = compile(filename=sass_fullname, include_paths=[_root_sass])
5351
with io.open(css_fullname, 'w', encoding='utf-8') as css_file:

test/subdir/recur.scss

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
2+
body {
3+
p { color: blue; }
4+
}

0 commit comments

Comments
 (0)